Skip to content

Commit 66821d9

Browse files
committed
Merge branch 'main' into support-overridden-attributes
2 parents 2d68cda + 5053c19 commit 66821d9

743 files changed

Lines changed: 46621 additions & 563312 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.config/dotnet-tools.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
"commands": [
88
"dotnet-format"
99
]
10+
},
11+
"docfx": {
12+
"version": "2.78.4",
13+
"commands": [
14+
"docfx"
15+
]
1016
}
1117
}
1218
}

.github/dependabot.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: 2
2+
updates:
3+
# NuGet packages - patch updates only for LTS stability
4+
- package-ecosystem: "nuget"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"
8+
ignore:
9+
# Only allow patch updates (ignore minor and major)
10+
- dependency-name: "*"
11+
update-types:
12+
- "version-update:semver-major"
13+
- "version-update:semver-minor"
14+
groups:
15+
nuget-patch:
16+
patterns:
17+
- "*"
18+
19+
# Sample and test projects - allow all updates (latest versions)
20+
- package-ecosystem: "nuget"
21+
directories:
22+
- "/docs/samples"
23+
- "/test"
24+
schedule:
25+
interval: "monthly"
26+
groups:
27+
microsoft-extensions:
28+
patterns:
29+
- "Microsoft.Extensions.*"
30+
test-dependencies:
31+
patterns:
32+
- "Microsoft.NET.Test.Sdk"
33+
- "xunit*"
34+
- "coverlet*"
35+
- "Moq"
36+
- "FluentAssertions"
37+
38+
# GitHub Actions - monthly updates
39+
- package-ecosystem: "github-actions"
40+
directory: "/"
41+
schedule:
42+
interval: "quarterly"
43+
groups:
44+
github-actions:
45+
patterns:
46+
- "*"

.github/workflows/ci.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,24 @@ jobs:
3333
package_version: ${{ steps.build_script.outputs.package_version }}
3434

3535
steps:
36-
- uses: actions/checkout@v4
36+
- uses: actions/checkout@v6
3737
- name: Setup .NET
38-
uses: actions/setup-dotnet@v4
38+
uses: actions/setup-dotnet@v5
3939
with:
4040
dotnet-version: |
41-
6.0.x
42-
8.0.x
41+
8.x
42+
9.x
43+
10.x
4344
- name: Run build script
4445
id: build_script
4546
run: ./build.ps1 -ci
46-
- uses: actions/upload-artifact@v4
47+
- uses: actions/upload-artifact@v6
4748
if: ${{ matrix.os == 'windows-latest' }}
4849
with:
4950
name: packages
5051
path: artifacts/
5152
if-no-files-found: error
52-
- uses: codecov/codecov-action@v4
53+
- uses: codecov/codecov-action@v5
5354
with:
5455
name: unittests-${{ matrix.os }}
5556
fail_ci_if_error: true
@@ -66,7 +67,7 @@ jobs:
6667
uses: NuGet/setup-nuget@v2
6768
with:
6869
nuget-version: latest
69-
- uses: actions/download-artifact@v4
70+
- uses: actions/download-artifact@v7
7071
with:
7172
name: packages
7273
path: packages

.github/workflows/docs.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ on:
1717

1818
jobs:
1919
generate_docs:
20-
runs-on: windows-latest
20+
runs-on: ubuntu-latest
2121

2222
steps:
23-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v6
2424
- name: Setup .NET
25-
uses: actions/setup-dotnet@v3
25+
uses: actions/setup-dotnet@v5
2626
with:
2727
dotnet-version: |
28-
6.0.x
29-
8.0.x
28+
8.x
29+
9.x
30+
10.x
3031
- name: Run docs generation
3132
run: ./docs/generate.ps1
3233

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
stale:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/stale@v5
16+
- uses: actions/stale@v10
1717
with:
1818
debug-only: ${{ github.event.inputs.debug-only == 'true' }}
1919
days-before-stale: 365

CLAUDE.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/claude-code) when working with this repository.
4+
5+
## Project Overview
6+
7+
**McMaster.Extensions.CommandLineUtils** is a .NET library for building command-line applications. It simplifies parsing command-line arguments, validating user inputs, and generating help text. This is a fork of Microsoft.Extensions.CommandLineUtils.
8+
9+
- **Package:** `McMaster.Extensions.CommandLineUtils` on NuGet
10+
- **Targets:** .NET 6.0+
11+
- **Status:** Stable/maintenance mode (no major features planned)
12+
- **License:** Apache 2.0
13+
14+
## Build Commands
15+
16+
```bash
17+
# Full build with tests (recommended)
18+
./build.ps1
19+
20+
# CI mode (enforces formatting checks)
21+
./build.ps1 -ci
22+
23+
# Build only
24+
dotnet build
25+
26+
# Run tests
27+
dotnet test
28+
29+
# Build sample projects
30+
dotnet build docs/samples/samples.sln
31+
32+
# Generate documentation locally
33+
./docs/generate.ps1
34+
./docs/generate.ps1 -Serve # with local preview
35+
```
36+
37+
Build outputs (NuGet packages) go to `/artifacts/`.
38+
39+
## Project Structure
40+
41+
```
42+
src/
43+
CommandLineUtils/ # Main library
44+
Attributes/ # Attribute-based API ([Option], [Argument], etc.)
45+
Conventions/ # Convention system for processing attributes
46+
Validation/ # Validation framework
47+
IO/ # Console I/O abstractions (IConsole)
48+
HelpText/ # Help text generation
49+
Internal/ # Parsing engine, value parsers
50+
Utilities/ # ArgumentEscaper, Prompt, DotNetExe
51+
Hosting.CommandLine/ # Microsoft.Extensions.Hosting integration
52+
53+
test/
54+
CommandLineUtils.Tests/ # xUnit tests for main library
55+
Hosting.CommandLine.Tests/ # xUnit tests for hosting package
56+
57+
docs/
58+
samples/ # 20+ example projects demonstrating various patterns
59+
```
60+
61+
## Two APIs
62+
63+
**1. Attribute-based API:**
64+
```csharp
65+
public class Program
66+
{
67+
public static int Main(string[] args)
68+
=> CommandLineApplication.Execute<Program>(args);
69+
70+
[Option(Description = "The subject")]
71+
public string Subject { get; } = "world";
72+
73+
private void OnExecute() { /* command logic */ }
74+
}
75+
```
76+
77+
**2. Builder API:**
78+
```csharp
79+
var app = new CommandLineApplication();
80+
app.HelpOption();
81+
var subject = app.Option("-s|--subject <SUBJECT>", "desc", CommandOptionType.SingleValue);
82+
app.OnExecute(() => { /* command logic */ });
83+
return app.Execute(args);
84+
```
85+
86+
## Key Patterns
87+
88+
- **Conventions:** Extensible `IConvention` implementations process attributes and wire up behavior
89+
- **Validation:** Three approaches - attribute validators (`[Required]`, `[FileExists]`), fluent API (`.IsRequired()`, `.Accepts()`), and `OnValidate()` methods
90+
- **Console abstraction:** `IConsole` interface enables testing; use `PhysicalConsole` for real I/O
91+
- **Response files:** Support for `@filename` syntax to read arguments from files
92+
93+
## Code Style
94+
95+
- 4-space indentation
96+
- Nullable reference types enabled
97+
- Warnings treated as errors
98+
- Code style enforced in build (`EnforceCodeStyleInBuild=true`)
99+
- Format check: `dotnet tool run dotnet-format`
100+
101+
## Testing
102+
103+
Uses xUnit with FluentAssertions and Moq. Convention tests inherit from `ConventionTestBase` and use `Create<T>()` factory method.
104+
105+
```bash
106+
dotnet test --collect:"XPlat Code Coverage"
107+
```

build.ps1

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ if (!$Configuration) {
1616
$Configuration = if ($ci) { 'Release' } else { 'Debug' }
1717
}
1818

19-
if (-not (Test-Path variable:\IsCoreCLR)) {
20-
$IsWindows = $true
21-
}
22-
2319
$artifacts = "$PSScriptRoot/artifacts/"
2420

2521
Remove-Item -Recurse $artifacts -ErrorAction Ignore
@@ -36,14 +32,6 @@ exec dotnet tool run dotnet-format -- -v detailed @formatArgs "$PSScriptRoot/doc
3632
exec dotnet build --configuration $Configuration '-warnaserror:CS1591'
3733
exec dotnet pack --no-build --configuration $Configuration -o $artifacts
3834
exec dotnet build --configuration $Configuration "$PSScriptRoot/docs/samples/samples.sln"
39-
40-
[string[]] $testArgs=@()
41-
if (-not $IsWindows) {
42-
$testArgs += '-p:TestFullFramework=false'
43-
}
44-
45-
exec dotnet test --no-build --configuration $Configuration `
46-
--collect:"XPlat Code Coverage" `
47-
@testArgs
35+
exec dotnet test --no-build --configuration $Configuration --collect:"XPlat Code Coverage"
4836

4937
write-host -f green 'BUILD SUCCEEDED'

0 commit comments

Comments
 (0)