diff --git a/README.md b/README.md index 8233ca3..1668c7e 100644 --- a/README.md +++ b/README.md @@ -74,75 +74,35 @@ This consolidates versions from all jobs and generates a markdown report. ## Command-Line Options -### Global Options - -| Option | Description | -| -------------------- | ------------------------------------------------------------ | -| `-v`, `--version` | Display version information | -| `-?`, `-h`, `--help` | Display help message | -| `--silent` | Suppress console output | -| `--log ` | Write output to log file | - -### Lint Mode - -Validate a `.versionmark.yaml` configuration file for issues: - -```bash -versionmark --lint [] -``` - -| Option | Description | -| ----------------------- | --------------------------------------------------------------------- | -| `--lint []`| Check configuration file (default: `.versionmark.yaml`) | - -Lint reports all issues with filename and line/column location. Exits with code 0 if no -issues are found, or 1 if any issues are detected. - -**Example:** - -```bash -# Lint the default config file -versionmark --lint - -# Lint a specific config file -versionmark --lint path/to/.versionmark.yaml -``` - -### Capture Mode - -Capture tool versions from the current environment: - -```bash -versionmark --capture --job-id [options] [-- tool1 tool2 ...] -``` - -| Option | Description | -| ------------------------- | ------------------------------------------------------------ | -| `--capture` | Enable capture mode | -| `--job-id ` | **(Required)** Unique identifier for this CI/CD job | -| `--output ` | Output JSON file (default: `versionmark-.json`) | -| `-- ` | List of tool names to capture (default: all tools in config) | - -**Example:** Capture specific tools only: - -```bash -versionmark --capture --job-id "windows-build" -- dotnet node npm -``` - -### Publish Mode - -Publish captured versions to markdown documentation: - -```bash -versionmark --publish --report [options] [-- pattern1 pattern2 ...] +```text +Usage: versionmark [options] + versionmark --lint [] + versionmark --capture --job-id [options] [-- tool1 tool2 ...] + versionmark --publish --report [options] [-- pattern1 pattern2 ...] ``` -| Option | Description | -| ------------------------- | ------------------------------------------------------------ | -| `--publish` | Enable publish mode | -| `--report ` | **(Required)** Output markdown file path | -| `--report-depth ` | Heading depth for markdown output (default: 2) | -| `-- ` | Glob patterns for JSON files (default: `versionmark-*.json`) | +| Option | Description | +| ------------------------- | ---------------------------------------------------------------- | +| **General** | | +| `-v`, `--version` | Display version information | +| `-?`, `-h`, `--help` | Display help message | +| `--silent` | Suppress console output | +| `--log ` | Write output to log file | +| **Lint Mode** | | +| `--lint []` | Check configuration file (default: `.versionmark.yaml`) | +| **Capture Mode** | | +| `--capture` | Enable capture mode | +| `--job-id ` | **(Required)** Unique identifier for this CI/CD job | +| `--output ` | Output JSON file (default: `versionmark-.json`) | +| `-- ` | List of tool names to capture (default: all tools in config) | +| **Publish Mode** | | +| `--publish` | Enable publish mode | +| `--report ` | **(Required)** Output markdown file path | +| `--report-depth ` | Heading depth for markdown output (default: 2, min: 1, max: 6) | +| `-- ` | Glob patterns for JSON files (default: `versionmark-*.json`) | +| **Self-Validation** | | +| `--validate` | Run self-validation tests | +| `--results ` | Write validation results to file (`.trx` or `.xml`) | ## Configuration File diff --git a/docs/user_guide/guide.md b/docs/user_guide/guide.md index d668b6e..7f5139f 100644 --- a/docs/user_guide/guide.md +++ b/docs/user_guide/guide.md @@ -86,18 +86,32 @@ This generates a markdown file consolidating versions from all jobs. # Command-Line Reference -## Global Options - -These options are available for all commands: - -| Option | Description | -| -------------------- | ------------------------------------------------------------ | -| `-v`, `--version` | Display version information | -| `-?`, `-h`, `--help` | Display help message | -| `--silent` | Suppress console output | -| `--log ` | Write output to log file | - -## Lint Command +## Options + +| Option | Description | +| ------------------------- | ---------------------------------------------------------------- | +| **General** | | +| `-v`, `--version` | Display version information | +| `-?`, `-h`, `--help` | Display help message | +| `--silent` | Suppress console output | +| `--log ` | Write output to log file | +| **Lint Mode** | | +| `--lint []` | Check configuration file (default: `.versionmark.yaml`) | +| **Capture Mode** | | +| `--capture` | Enable capture mode | +| `--job-id ` | **(Required)** Unique identifier for this CI/CD job | +| `--output ` | Output JSON file (default: `versionmark-.json`) | +| `-- ` | List of tool names to capture (default: all tools in config) | +| **Publish Mode** | | +| `--publish` | Enable publish mode | +| `--report ` | **(Required)** Output markdown file path | +| `--report-depth ` | Heading depth for markdown output (default: 2, min: 1, max: 6) | +| `-- ` | Glob patterns for JSON files (default: `versionmark-*.json`) | +| **Self-Validation** | | +| `--validate` | Run self-validation tests | +| `--results ` | Write validation results to file (`.trx` or `.xml`) | + +## Lint Mode Validate a `.versionmark.yaml` configuration file for issues: @@ -105,12 +119,6 @@ Validate a `.versionmark.yaml` configuration file for issues: versionmark --lint [] ``` -### Lint Options - -| Option | Description | -| ------------------------ | ---------------------------------------------------------------- | -| `--lint []` | Check configuration file (default: `.versionmark.yaml`) | - ### Lint Behavior The lint command: @@ -157,7 +165,7 @@ For example: .versionmark.yaml(8,5): error: Tool 'node' 'regex' contains an invalid regex: ... ``` -## Capture Command +## Capture Mode Capture tool versions from the current environment: @@ -165,18 +173,7 @@ Capture tool versions from the current environment: versionmark --capture --job-id [options] [-- tool1 tool2 ...] ``` -### Options - -| Option | Description | -| ------------------------- | ----------------------------------------------------------------------------------- | -| `--capture` | Enable capture mode | -| `--job-id ` | **(Required)** Unique identifier for this CI/CD job. This is used to differentiate | -| | versions captured in different environments or configurations. | -| `--output ` | Path to output JSON file (default: `versionmark-.json`) | -| `-- ` | List of tool names to capture. If not specified, all tools defined in the | -| | configuration file will be captured. | - -### Example +### Examples ```bash # Capture all tools defined in config @@ -189,7 +186,7 @@ versionmark --capture --job-id "linux-gcc" -- gcc make cmake versionmark --capture --job-id "macos" --output versions/macos.json ``` -## Publish Command +## Publish Mode Publish captured versions to markdown documentation: @@ -197,15 +194,6 @@ Publish captured versions to markdown documentation: versionmark --publish --report [options] [-- pattern1 pattern2 ...] ``` -### Publish Options - -| Option | Description | -| ------------------------ | ---------------------------------------------------------------- | -| `--publish` | Enable publish mode | -| `--report ` | **(Required)** Path to output markdown file | -| `--report-depth ` | Heading depth for markdown output (default: 2, min: 1, max: 6) | -| `-- ` | Glob patterns for JSON files (default: `versionmark-*.json`) | - ### Publish Examples ```bash diff --git a/src/DemaConsulting.VersionMark/Cli/Context.cs b/src/DemaConsulting.VersionMark/Cli/Context.cs index 3614308..224b809 100644 --- a/src/DemaConsulting.VersionMark/Cli/Context.cs +++ b/src/DemaConsulting.VersionMark/Cli/Context.cs @@ -345,6 +345,7 @@ private int ParseArgument(string arg, string[] args, int index) LogFile = GetRequiredStringArgument(arg, args, index, "a filename argument"); return index + 1; + case "--result": case "--results": ResultsFile = GetRequiredStringArgument(arg, args, index, "a results filename argument"); return index + 1; diff --git a/test/DemaConsulting.VersionMark.Tests/Cli/ContextTests.cs b/test/DemaConsulting.VersionMark.Tests/Cli/ContextTests.cs index 59aaa79..dc6d979 100644 --- a/test/DemaConsulting.VersionMark.Tests/Cli/ContextTests.cs +++ b/test/DemaConsulting.VersionMark.Tests/Cli/ContextTests.cs @@ -162,6 +162,20 @@ public void Context_Create_ResultsFlag_SetsResultsFile() Assert.AreEqual(0, context.ExitCode); } + /// + /// Test creating a context with the legacy result flag (alias for --results). + /// + [TestMethod] + public void Context_Create_ResultFlag_SetsResultsFile() + { + // Arrange & Act - Create context with --result flag (legacy alias) + using var context = Context.Create(["--result", "test.trx"]); + + // Assert - Verify results file is set + Assert.AreEqual("test.trx", context.ResultsFile); + Assert.AreEqual(0, context.ExitCode); + } + /// /// Test creating a context with the log flag. ///