Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 Core/NetArgumentParser/NetArgumentParser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<PackageId>NetArgumentParser</PackageId>
<Version>1.1.0</Version>
<Version>1.1.1</Version>
<Product>NetArgumentParser</Product>
<Title>NetArgumentParser</Title>
<Authors>yakovypg</Authors>
<Company>yakovypg</Company>
<Copyright>Copyright © yakovypg 2024–2026</Copyright>
<PackageTags>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</PackageTags>
<Description>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.</Description>
<Description>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.</Description>
<PackageProjectUrl>https://github.com/yakovypg/NetArgumentParser</PackageProjectUrl>
<RepositoryUrl>https://github.com/yakovypg/NetArgumentParser</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public OptionValueNotSatisfyChoicesException(
message ?? GetDefaultMessage(optionValue, allowedValues),
optionValue,
allowedValues,
null) { }
null)
{ }

public OptionValueNotSatisfyChoicesException(
string? message,
Expand Down
10 changes: 5 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<ItemGroup>
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="Microsoft.CSharp" Version="4.3.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
<PackageVersion Include="coverlet.collector" Version="10.0.1" />
</ItemGroup>

</Project>
30 changes: 15 additions & 15 deletions Documentation/ConnectProject.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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**.
Expand All @@ -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
```
201 changes: 201 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<a href="https://github.com/yakovypg/NetArgumentParser/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-GPLv3-darkyellow.svg" alt="license" />
</a>
<img src="https://img.shields.io/badge/Version-1.1.0-red.svg" alt="version" />
<img src="https://img.shields.io/badge/Version-1.1.1-red.svg" alt="version" />
<img src="https://img.shields.io/badge/C%23-12.0-blue" alt="csharp" />
</p>

## 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.

[![NuGet Badge](https://img.shields.io/nuget/v/NetArgumentParser)](https://www.nuget.org/packages/NetArgumentParser/)
[![Contributors](https://img.shields.io/github/contributors/yakovypg/NetArgumentParser)](https://github.com/yakovypg/NetArgumentParser/graphs/contributors)
Expand Down
14 changes: 7 additions & 7 deletions Tests/NetArgumentParser.Tests/ArgumentParserSubcommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down
Loading
Loading