Skip to content

Add CLI file output#37

Merged
HandyS11 merged 2 commits intodevelopfrom
007-cli-file-output
Feb 24, 2026
Merged

Add CLI file output#37
HandyS11 merged 2 commits intodevelopfrom
007-cli-file-output

Conversation

@HandyS11
Copy link
Copy Markdown
Owner

This pull request introduces a new --output flag for CLI commands, enabling users to save generated diagrams directly to disk rather than relying on shell redirection. The feature is implemented across visualize, class-diagram, and erd commands, with robust error handling, markdown fencing logic, and confirmation messaging. The change is thoroughly documented and tested, with updates to abstractions, command settings, and integration tests.

CLI Command Enhancements:

  • Added --output flag (-o|--output <path>) to ClassDiagramCommand, ErdCommand, and (implied) VisualizeCommand, allowing diagrams to be written directly to a file instead of stdout. [1] [2]
  • Updated command execution logic to use IFileSystem for file writing, including automatic directory creation and consistent UTF-8 encoding.
  • Implemented markdown fencing logic: diagrams are wrapped in a code fence if the output file extension is .md or anything other than .mmd.

Documentation & Specification:

  • Added comprehensive feature specification, implementation plan, research notes, data model summary, quickstart guide, and tasks checklist for the new file output feature in specs/007-cli-file-output/. [1] [2] [3] [4] [5] [6] [7]

User Experience Improvements:

  • CLI now prints a confirmation message ("Saved to ") when a file is written, and provides clear error reporting for permission or path issues. [1] [2]

Repository and Workflow Updates:

  • Renamed Nuget.config to NuGet.config for consistency and added a new documentation publishing workflow to .github/workflows/. [1] [2]

README Updates:

  • Updated CLI usage examples to reflect the new --output flag, replacing shell redirection with direct file output. [1] [2]

References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

Copilot AI review requested due to automatic review settings February 24, 2026 08:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a --output flag to the CLI commands (visualize, erd, classdiagram), enabling users to save generated diagrams directly to disk with proper encoding (UTF-8 without BOM) and automatic markdown fencing based on file extension. The feature addresses issues with shell redirection on Windows PowerShell and improves CI/CD integration by providing reliable file output.

Changes:

  • Added WriteAllTextAsync and CreateDirectory methods to IFileSystem interface and PhysicalFileSystem implementation
  • Implemented --output flag in all three CLI commands with consistent file handling logic and markdown fencing based on extension (.mmd = no fence, others = fence)
  • Added comprehensive unit and integration tests covering UTF-8 encoding, directory creation, and markdown fencing scenarios
  • Updated documentation (README, CLI README, specifications) to showcase the new feature with clear examples

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/ProjGraph.Lib.Core/Abstractions/IFileSystem.cs Added WriteAllTextAsync and CreateDirectory methods to enable file writing operations
src/ProjGraph.Lib.Core/Infrastructure/PhysicalFileSystem.cs Implemented new IFileSystem methods with UTF-8 encoding (no BOM) and directory creation
src/ProjGraph.Cli/Commands/VisualizeCommand.cs Added --output flag, file writing logic, and markdown fencing based on extension
src/ProjGraph.Cli/Commands/ErdCommand.cs Added --output flag, file writing logic, and markdown fencing based on extension
src/ProjGraph.Cli/Commands/ClassDiagramCommand.cs Added --output flag, file writing logic, and markdown fencing based on extension
src/ProjGraph.Cli/Program.cs Added examples demonstrating the new --output flag for all three commands
tests/ProjGraph.Tests.Unit.Core/PhysicalFileSystemTests.cs Unit tests verifying UTF-8 encoding (no BOM), directory creation, and file operations
tests/ProjGraph.Tests.Integration.Cli/VisualizeCommandTests.cs Integration tests for both .md (with fence) and .mmd (without fence) output scenarios
tests/ProjGraph.Tests.Integration.Cli/ErdCommandTests.cs Integration test for .md file output with markdown fencing
tests/ProjGraph.Tests.Integration.Cli/ClassDiagramCommandTests.cs Integration test for .md file output with markdown fencing
README.md Updated examples to show new --output flag usage instead of shell redirection
src/ProjGraph.Cli/README.md Comprehensive documentation of --output flag for all commands with examples
ProjGraph.slnx Renamed Nuget.config to NuGet.config (proper casing) and added docs-publish.yml workflow reference
specs/007-cli-file-output/*.md Complete feature specification including requirements, implementation plan, tasks, and quickstart guide

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread specs/007-cli-file-output/spec.md Outdated
Comment thread specs/007-cli-file-output/data-model.md
Comment thread specs/007-cli-file-output/spec.md Outdated
@HandyS11 HandyS11 merged commit 218d926 into develop Feb 24, 2026
5 checks passed
@HandyS11 HandyS11 deleted the 007-cli-file-output branch February 24, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants