diff --git a/Core/NetArgumentParser/NetArgumentParser.csproj b/Core/NetArgumentParser/NetArgumentParser.csproj
index 156f848..4d0195e 100644
--- a/Core/NetArgumentParser/NetArgumentParser.csproj
+++ b/Core/NetArgumentParser/NetArgumentParser.csproj
@@ -2,14 +2,14 @@
NetArgumentParser
- 1.1.0
+ 1.1.1
NetArgumentParser
NetArgumentParser
yakovypg
yakovypg
Copyright © yakovypg 2024–2026
cli;options;args;command-line;argument-parser;arguments;cli-args;argument-parsing;subcommands;argparse;command-line-parser;flags;cli-parser;command-line-arguments;cli-arguments;net-argparse;csharp-argparse;subcommand-parser
- NetArgumentParser is a cross-platform, free and open source library for parsing command-line options, arguments and subcommands. It contains the main features of popular argument parsers such as argparse, as well as many of its own.
+ NetArgumentParser is a cross-platform, free, open source C# library for parsing command-line options, arguments and subcommands. It contains the main features of popular argument parsers such as argparse, as well as many of its own.
https://github.com/yakovypg/NetArgumentParser
https://github.com/yakovypg/NetArgumentParser
git
diff --git a/Core/NetArgumentParser/Options/OptionValueNotSatisfyChoicesException.cs b/Core/NetArgumentParser/Options/OptionValueNotSatisfyChoicesException.cs
index 8459577..ec03359 100644
--- a/Core/NetArgumentParser/Options/OptionValueNotSatisfyChoicesException.cs
+++ b/Core/NetArgumentParser/Options/OptionValueNotSatisfyChoicesException.cs
@@ -28,7 +28,8 @@ public OptionValueNotSatisfyChoicesException(
message ?? GetDefaultMessage(optionValue, allowedValues),
optionValue,
allowedValues,
- null) { }
+ null)
+ { }
public OptionValueNotSatisfyChoicesException(
string? message,
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 3361061..28d0a6b 100755
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -6,11 +6,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/Documentation/ConnectProject.md b/Documentation/ConnectProject.md
index 8bafbd6..a1b79a0 100644
--- a/Documentation/ConnectProject.md
+++ b/Documentation/ConnectProject.md
@@ -3,7 +3,7 @@ Here you can see instructions for connecting **NetArgumentParser** to your proje
## General
At fitst, you need to clone **NetArgumentParser** repository and [add reference](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-add-reference) to the library:
-```
+```bash
dotnet add path_to_your_project.csproj reference path_to_lib/Core/NetArgumentParser
```
@@ -21,47 +21,47 @@ Finally, you can work with the parser.
## Step-By-Step Connection
Let's consider this step-by-step instructions for creating a sample project and connecting this library to it.
- Step 1: Go to the directory with your projects.
-```
+```bash
cd ~/Repos
```
- Step 2: Create folder for your project and move to it.
-```
+```bash
mkdir MyProject && cd MyProject
```
- Step 3: Create solution.
-```
+```bash
dotnet new sln
```
- Step 4: Create your project.
-```
+```bash
dotnet new console -o MyProject
```
- Step 5: Add your project to the solution.
-```
+```bash
dotnet sln add ./MyProject
```
- Step 6: Add folder for external projects and go to it.
-```
+```bash
mkdir Vendor && cd Vendor
```
- Step 7: Clone **NetArgumentParser** repository.
-```
+```bash
git clone https://github.com/yakovypg/NetArgumentParser.git
```
- Step 8: Move back to the root folder.
-```
+```bash
cd ..
```
-- Step 9: Add **NetArgumentParser** to the solution.
-```
+- Step 9: Add **NetArgumentParser** to the solution.
+```bash
dotnet sln add Vendor/NetArgumentParser/Core/NetArgumentParser
```
- Step 10: Move to your project folder.
-```
+```bash
cd MyProject
```
- Step 11: Add reference to the **NetArgumentParser**.
-```
+```bash
dotnet add reference ../Vendor/NetArgumentParser/Core/NetArgumentParser
```
- Step 12: Open Program.cs file and try using the **NetArgumentParser**.
@@ -85,10 +85,10 @@ Console.WriteLine($"Angle: {angle}");
Console.WriteLine($"Extra arguments: {string.Join(' ', extraArguments)}");
```
- Step 13: Build the project.
-```
+```bash
dotnet build -c Release
```
- Step 14: Run the created application.
-```
+```bash
dotnet run --angle 45 A
```
diff --git a/NOTICE.md b/NOTICE.md
new file mode 100644
index 0000000..20cdca6
--- /dev/null
+++ b/NOTICE.md
@@ -0,0 +1,201 @@
+# Third-Party Notices and License Information
+
+This file lists third-party components included in this project, their copyrights, and license texts or references.
+
+## StyleCop.Analyzers
+
+MIT License
+
+Copyright (c) Tunnel Vision Laboratories, LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+## Microsoft.CSharp
+
+The MIT License (MIT)
+
+Copyright (c) .NET Foundation and Contributors
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+## Microsoft.NET.Test.Sdk
+
+The MIT License (MIT)
+
+Copyright (c) Microsoft Corporation
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+## xunit
+
+Unless otherwise noted, the source code here is covered by the following license:
+
+ Copyright (c) .NET Foundation and Contributors
+ All Rights Reserved
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+The source in src/xunit.v3.runner.common/Utility/ConsoleHelper.cs was adapted from code
+that is covered the following license (copied from
+https://github.com/Microsoft/msbuild/blob/ab090d1255caa87e742cbdbc6d7fe904ecebd975/LICENSE):
+
+ MSBuild
+
+ The MIT License (MIT)
+
+ Copyright (c) .NET Foundation and contributors
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+## xunit.runner.visualstudio
+
+Unless otherwise noted, the source code here is covered by the following license:
+
+ Copyright (c) .NET Foundation and Contributors
+ All Rights Reserved
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-----------------------
+
+The code in src/xunit.runner.visualstudio/Utility/AssemblyResolution/Microsoft.DotNet.PlatformAbstractions was imported from:
+ https://github.com/dotnet/core-setup/tree/v2.0.1/src/managed/Microsoft.DotNet.PlatformAbstractions
+
+The code in src/xunit.runner.visualstudio/Utility/AssemblyResolution/Microsoft.Extensions.DependencyModel was imported from:
+ https://github.com/dotnet/core-setup/tree/v2.0.1/src/managed/Microsoft.Extensions.DependencyModel
+
+Both sets of code are covered by the following license:
+
+ The MIT License (MIT)
+
+ Copyright (c) 2015 .NET Foundation
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+## coverlet.collector
+
+The MIT License (MIT)
+
+Copyright (c) 2018 Toni Solarin-Sodara
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index 2c996be..96dff21 100644
--- a/README.md
+++ b/README.md
@@ -7,14 +7,14 @@
-
+
## About
-**NetArgumentParser** is a cross-platform, free, open source library for parsing command-line options, arguments and subcommands. This library contains the main features of popular argument parsers such as `argparse`, as well as many of its own.
+**NetArgumentParser** is a cross-platform, free, open source C# library for parsing command-line options, arguments and subcommands. This library contains the main features of popular argument parsers such as `argparse`, as well as many of its own.
-**NetArgumentParser** supports many frameworks, so you can use it in most of your projects. Moreover, you can find clear examples of using this library [here](Examples).
+**NetArgumentParser** supports many frameworks, so you can use it in most of your projects. Moreover, you can find clear examples of using this library [here](Examples). You may also find it helpful to look at the example of **NetArgumentParser** integration in the [Ypdf.CommandLine](https://github.com/yakovypg/Ypdf.CommandLine) project — a cross-platform command-line tool for PDF processing. It is a full, end-to-end integration example.
[](https://www.nuget.org/packages/NetArgumentParser/)
[](https://github.com/yakovypg/NetArgumentParser/graphs/contributors)
diff --git a/Tests/NetArgumentParser.Tests/ArgumentParserSubcommandTests.cs b/Tests/NetArgumentParser.Tests/ArgumentParserSubcommandTests.cs
index ae382f7..6866929 100644
--- a/Tests/NetArgumentParser.Tests/ArgumentParserSubcommandTests.cs
+++ b/Tests/NetArgumentParser.Tests/ArgumentParserSubcommandTests.cs
@@ -1445,10 +1445,10 @@ public void Parse_HelpOption_ArgumentsParseResultIsCorrect()
Assert.True(help);
- Assert.Equal(1, result.HandledOptions.Count);
+ Assert.Single(result.HandledOptions);
Assert.Equal(expectedHelpOption, result.HandledOptions.First());
- Assert.Equal(1, result.HandledSubcommands.Count);
+ Assert.Single(result.HandledSubcommands);
Assert.Equal(subcommand1, result.HandledSubcommands.First());
}
@@ -1612,10 +1612,10 @@ public void Parse_VersionOption_ArgumentsParseResultIsCorrect()
Assert.True(version);
- Assert.Equal(1, result.HandledOptions.Count);
+ Assert.Single(result.HandledOptions);
Assert.Equal(expectedVersionOption, result.HandledOptions.First());
- Assert.Equal(1, result.HandledSubcommands.Count);
+ Assert.Single(result.HandledSubcommands);
Assert.Equal(subcommand1, result.HandledSubcommands.First());
}
@@ -1792,10 +1792,10 @@ public void Parse_FinalOption_ArgumentsParseResultIsCorrect()
Assert.Equal(expectedFinalOptionValue, finalOptionValue);
- Assert.Equal(1, result.HandledOptions.Count);
+ Assert.Single(result.HandledOptions);
Assert.Equal(expectedFinalOption, result.HandledOptions.First());
- Assert.Equal(1, result.HandledSubcommands.Count);
+ Assert.Single(result.HandledSubcommands);
Assert.Equal(subcommand1, result.HandledSubcommands.First());
}
@@ -1903,7 +1903,7 @@ public void Parse_RequiredOptions_ArgumentsParseResultIsCorrect()
ParseArgumentsResult result = parser.ParseKnownArguments(arguments, out _);
Assert.Equal(4, result.HandledOptions.Count);
- Assert.Equal(1, result.HandledSubcommands.Count);
+ Assert.Single(result.HandledSubcommands);
Assert.Equal(subcommand1, result.HandledSubcommands.First());
}
diff --git a/Tests/NetArgumentParser.Tests/NetArgumentParser.Tests.csproj b/Tests/NetArgumentParser.Tests/NetArgumentParser.Tests.csproj
index 1481a5a..31aa3d0 100644
--- a/Tests/NetArgumentParser.Tests/NetArgumentParser.Tests.csproj
+++ b/Tests/NetArgumentParser.Tests/NetArgumentParser.Tests.csproj
@@ -1,6 +1,6 @@
-
+
net6.0;net7.0;net8.0;
diff --git a/Tests/NetArgumentParser.Tests/ParserGeneratorTests.cs b/Tests/NetArgumentParser.Tests/ParserGeneratorTests.cs
index f028294..6491f16 100644
--- a/Tests/NetArgumentParser.Tests/ParserGeneratorTests.cs
+++ b/Tests/NetArgumentParser.Tests/ParserGeneratorTests.cs
@@ -151,7 +151,7 @@ public void ConfigureParser_ParseSpecificConfig_ConfiguredCorrectly()
});
Assert.NotNull(finalGroup);
- Assert.Equal(1, finalGroup.Options.Count);
+ Assert.Single(finalGroup.Options);
Assert.Equal(
ParseSpecificParserGeneratorConfig.MutuallyExclusiveFinalOptionGroupHeader,
@@ -241,7 +241,7 @@ public void ConfigureParser_MutuallyExclusiveOptionGroup_CreatedGroupWithCorrect
generator.ConfigureParser(argumentParser, config);
- Assert.Equal(1, argumentParser.MutuallyExclusiveOptionGroups.Count);
+ Assert.Single(argumentParser.MutuallyExclusiveOptionGroups);
MutuallyExclusiveOptionGroup group =
argumentParser.MutuallyExclusiveOptionGroups[0];
@@ -307,7 +307,7 @@ public void ConfigureParser_HelpOption_OptionHandledActionsConfiguredCorrectly()
]);
Assert.Empty(result.HandledSubcommands);
- Assert.Equal(1, result.HandledOptions.Count);
+ Assert.Single(result.HandledOptions);
Assert.True(config.ShowHelp);
Assert.False(config.ShowVersion);
@@ -340,7 +340,7 @@ public void ConfigureParser_VersionOption_OptionHandledActionsConfiguredCorrectl
]);
Assert.Empty(result.HandledSubcommands);
- Assert.Equal(1, result.HandledOptions.Count);
+ Assert.Single(result.HandledOptions);
Assert.False(config.ShowHelp);
Assert.True(config.ShowVersion);
@@ -805,7 +805,7 @@ private static void VerifyFlagOptionsOnlyParserGeneratorConfigQuantum(ParserQuan
Assert.Empty(quantum.Subcommands);
- Assert.Equal(1, quantum.OptionGroups.Count);
+ Assert.Single(quantum.OptionGroups);
Assert.Equal(quantum.DefaultGroup, quantum.OptionGroups[0]);
Assert.Equal(3, quantum.Options.Count);
@@ -922,7 +922,7 @@ private static void VerifySubcommandsOnlyParserGeneratorConfigQuantum(ParserQuan
Assert.Empty(quantum.Options);
- Assert.Equal(1, quantum.OptionGroups.Count);
+ Assert.Single(quantum.OptionGroups);
Assert.Equal(quantum.DefaultGroup, quantum.OptionGroups[0]);
Assert.Equal(3, quantum.Subcommands.Count);
@@ -991,7 +991,7 @@ private static void VerifyComplexParserGeneratorConfigQuantum(ParserQuantum quan
});
Assert.NotNull(defaultGroup);
- Assert.Equal(1, defaultGroup.Options.Count);
+ Assert.Single(defaultGroup.Options);
ICommonOption? verbosityLevelOptionInDefaultGroup = defaultGroup.Options.FirstOrDefault(t =>
{
@@ -1536,10 +1536,10 @@ private static void VerifyParseSpecificParserGeneratorConfigQuantum(ParserQuantu
{
ExtendedArgumentNullException.ThrowIfNull(quantum, nameof(quantum));
- Assert.Equal(1, quantum.OptionGroups.Count);
+ Assert.Single(quantum.OptionGroups);
Assert.Equal(quantum.DefaultGroup, quantum.OptionGroups[0]);
- Assert.Equal(1, quantum.Subcommands.Count);
+ Assert.Single(quantum.Subcommands);
Subcommand? complexSubcommand = quantum.Subcommands.FirstOrDefault(t =>
{
@@ -1622,7 +1622,7 @@ private static void VerifyParserQuantumIsEmpty(ParserQuantum quantum)
Assert.Empty(quantum.Subcommands);
Assert.Empty(quantum.Options);
- Assert.Equal(1, quantum.OptionGroups.Count);
+ Assert.Single(quantum.OptionGroups);
Assert.Equal(quantum.DefaultGroup, quantum.OptionGroups[0]);
}
}