Skip to content

Feature/cli graph export - #440

Merged
NovaCode37 merged 2 commits into
NovaCode37:mainfrom
marioalbu08:feature/cli-graph-export
Oct 1, 2026
Merged

NovaCode37 merged 2 commits into
NovaCode37:mainfrom
marioalbu08:feature/cli-graph-export

Conversation

@marioalbu08

Copy link
Copy Markdown
Contributor

Summary

Resolves #435 by adding --graphml and --gexf flags to the prism scan CLI, allowing users to export the generated entity graph to standard graph formats directly from the command line.

Changes

  • cli.py:
    • Added --graphml and --gexf to argparse configuration.
    • Implemented a DRY _output_graph function that uses modules.graph_export to generate the files.
    • Configured default filename generation (graph_<target>_<timestamp>.<ext>) to match HTML/PDF report behavior.
    • Updated the output dispatch logic in main() to support outputting graphs concurrently with existing report formats.
  • tests/test_cli.py: Added test suite covering the new flags using a mocked run_scan fixture to verify proper file creation without making network calls.

Type of change

  • New feature

Testing

  • I have tested these changes locally
  • I have added tests as needed

@github-actions

Copy link
Copy Markdown

Thanks for the first pull request here. CI needs a maintainer to approve the run before it starts, so it may sit for a bit before anything happens. pytest tests/ -q passing is the main thing I look at.

@github-actions github-actions Bot added the python Pull requests that update python code label Sep 30, 2026
Comment thread tests/test_cli.py Fixed
Comment thread tests/test_cli.py Fixed
@NovaCode37

Copy link
Copy Markdown
Owner

Thanks, reusing to_graphml / to_gexf is exactly right. Three things:

1. Conflict. #438 landed first and also created tests/test_cli.py. Rebase on main and move your two tests into that file.

2. -o overwrites. Every format writes to the same -o path, so --graphml --gexf -o out leaves only the GEXF, and --graphml --html -o report leaves only the HTML. When more than one output is requested, derive the graph file names from -o by extension (out.graphml, out.gexf), or reject the combination with exit 2 and a clear message. Either is fine; silently losing a file is not.

3. Tests write into the repo's results/. They depend on the working directory and leave files behind if a run is interrupted. Pass -o pointing into pytest's tmp_path and assert on that file instead, which also lets you drop the cleanup fixture. A test for case 2 would be good too.

@marioalbu08
marioalbu08 force-pushed the feature/cli-graph-export branch from 4634772 to 9fc5061 Compare October 1, 2026 11:56
@NovaCode37
NovaCode37 merged commit bc90961 into NovaCode37:main Oct 1, 2026
8 checks passed
@NovaCode37 NovaCode37 added the hacktoberfest-accepted Counts toward Hacktoberfest label Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted Counts toward Hacktoberfest python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export the graph as GraphML / GEXF from the CLI, as the web UI already does

3 participants