Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/design/sarifmark/cli/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ This satisfies requirements `SarifMark-Context-Create` through `SarifMark-Contex
| `ReportFile` | `string?` | `null` | `--report <file>` | Path to the markdown report output file |
| `ReportDepth` | `int` | `1` | `--report-depth <depth>` | Markdown heading depth for the report |
| `Heading` | `string?` | `null` | `--heading <text>` | Custom heading text for the report |
| `ResultsFile` | `string?` | `null` | `--results <file>` | Path for the self-validation results file |
| `ResultsFile` | `string?` | `null` | `--results <file>`, `--result <file>` | Path for the self-validation results file (`--result` is a legacy alias for `--results`) |
| `ExitCode` | `int` | `0`/`1` | *(derived)* | 0 until `WriteError` is called, then 1 |

These properties satisfy requirements `SarifMark-Context-VersionFlag`, `SarifMark-Context-HelpFlag`,
`SarifMark-Context-SilentFlag`, `SarifMark-Context-ValidateFlag`, `SarifMark-Context-EnforceFlag`,
`SarifMark-Context-SarifParam`, `SarifMark-Context-ReportParam`, `SarifMark-Context-ReportDepthParam`,
`SarifMark-Context-HeadingParam`, `SarifMark-Context-ResultsParam`, and `SarifMark-Context-ExitCode`.
`SarifMark-Context-HeadingParam`, `SarifMark-Context-ResultsParam`, `SarifMark-Context-ResultLegacyAlias`, and `SarifMark-Context-ExitCode`.

## ArgumentParser Inner Class

Expand Down
11 changes: 11 additions & 0 deletions docs/reqstream/sarifmark/cli/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,14 @@ sections:
- SarifMark-Context-ResultsParam
tests:
- Cli_ResultsParameter_SetsResultsFilePath

- id: SarifMark-Cli-ResultLegacyAlias
title: The CLI shall accept --result as a legacy alias for --results.
justification: >-
Supporting the legacy --result alias preserves backwards compatibility for users and scripts
that relied on the earlier parameter name, avoiding breaking changes in automated workflows.
tags: [public]
children:
- SarifMark-Context-ResultLegacyAlias
tests:
- Cli_ResultLegacyAlias_SetsResultsFilePath
9 changes: 9 additions & 0 deletions docs/reqstream/sarifmark/cli/context.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ sections:
tests:
- Context_Create_ResultsParameter_SetsResultsFile

- id: SarifMark-Context-ResultLegacyAlias
title: The Create method shall accept --result as a legacy alias for --results and set the ResultsFile property.
justification: >-
Accepting the legacy --result alias preserves backwards compatibility for existing scripts and
workflows that used the earlier parameter name, preventing breaking changes when users upgrade.
tags: [internal]
tests:
- Cli_ResultLegacyAlias_SetsResultsFilePath
Comment thread
Malcolmnixon marked this conversation as resolved.
Outdated

- id: SarifMark-Context-LogParam
title: The Create method shall parse the --log parameter and open the specified log file for writing.
justification: >-
Expand Down
1 change: 1 addition & 0 deletions src/DemaConsulting.SarifMark/Cli/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ private int ParseArgument(string arg, string[] args, int index)
Heading = GetRequiredStringArgument(arg, args, index, "a heading text argument");
return index + 1;

case "--result": // Legacy alias for --results to preserve backwards compatibility
case "--results":
ResultsFile = GetRequiredStringArgument(arg, args, index, "a results filename argument");
return index + 1;
Comment thread
Malcolmnixon marked this conversation as resolved.
Expand Down
14 changes: 14 additions & 0 deletions test/DemaConsulting.SarifMark.Tests/Cli/CliTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,18 @@ public void Cli_ResultsParameter_SetsResultsFilePath()
Assert.AreEqual("results.trx", context.ResultsFile);
Assert.AreEqual(0, context.ExitCode);
}

/// <summary>
/// Test that the legacy --result alias sets the results file path in context.
/// </summary>
[TestMethod]
public void Cli_ResultLegacyAlias_SetsResultsFilePath()
{
// Act
using var context = Context.Create(["--result", "results.trx"]);

// Assert
Assert.AreEqual("results.trx", context.ResultsFile);
Assert.AreEqual(0, context.ExitCode);
}
}
Loading