You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[System.CommandLine](https://github.com/dotnet/command-line-api) is a really handy .Net library for parsing command line arguments passed to an application. Unfortunately some useful features available in its beta stage were removed from the library's release candidates. CommandLineX brings back some of them: **hosting extensions** and **arguments model binding** including DI.
5
+
6
+
## Getting Started
7
+
### Creating Console App
8
+
1. Open terminal in the directory where your project usually are located.
9
+
1. Execute
10
+
```sh
11
+
dotnet new console -n MyConsoleApp --no-restore
12
+
```
13
+
1. Navigate to the project directory.
14
+
1. Open `MyConsoleApp.csproj` in XML editor of your choice.
15
+
1. Change project SDK by replacing `<Project Sdk="Microsoft.NET.Sdk">` with `<Project Sdk="Microsoft.NET.Sdk.Worker">` (needed for hosting integration).
16
+
17
+
### Installing The Library
18
+
In the directory of your project execute
19
+
```sh
20
+
dotnet add package diVISION.CommandLineX
21
+
```
22
+
23
+
### Integrating The Library
24
+
1. Create `MyFirstAction.cs` (command action model) in your project directory:
Execute one of the following in your project directory
89
+
```sh
90
+
dotnet run -- myFirst 42
91
+
```
92
+
```sh
93
+
dotnet run -- myFirst 42 43
94
+
```
95
+
```sh
96
+
dotnet run -- myFirst 42 43 -d someOtherDirectory
97
+
```
98
+
You can also request help on commands like
99
+
```sh
100
+
dotnet run -- -?
101
+
```
102
+
```sh
103
+
dotnet run -- myFirst -?
104
+
```
105
+
106
+
## Building
107
+
For building the application .NET SDK 8.x is required (recommended: Visual Studio or Visual Studio Code).
108
+
109
+
After cloning the repository you can either open the solution `CommandLineX.sln` in your IDE and hit "Build" or open the terminal in the solution directory and execute
110
+
```sh
111
+
dotnet build
112
+
```
113
+
114
+
## Contributing
115
+
All contributions to development and error fixing are welcome. Please always use `develop` branch for forks and pull requests, `main` is reserved for stable releases and critical vulnarability fixes only. All code changes should meet minimal code coverage requirements to be merged into `main` or `develop`, the coverage requirements are: lines - 95%, branches - 95%, methods - 100%.
Copy file name to clipboardExpand all lines: test/CommandLineX.Tests/CommmandLineHostingExtensionTest.cs
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -167,7 +167,7 @@ public async Task RunCommandLineAsync_throwing_Exception_given_hosted_invocation
167
167
168
168
usingvarhost=builder.Build();
169
169
host.Should().NotBeNull();
170
-
awaithost.Invoking(async x =>awaitx.RunCommandLineAsync(["onearg","66"],TestContext.CancellationTokenSource.Token)).Should().ThrowAsync<InvalidOperationException>();
170
+
awaithost.Invoking(async x =>awaitx.RunCommandLineAsync(["onearg","66"],TestContext.CancellationToken)).Should().ThrowAsync<InvalidOperationException>();
171
171
}
172
172
173
173
[TestMethod]
@@ -186,7 +186,7 @@ public async Task RunCommandLineAsync_returning_result_of_ComplexArgAndOptionCom
@@ -236,7 +236,7 @@ public async Task RunCommandLineHostedAsync_throwing_Exception_given_missing_Com
236
236
237
237
usingvarhost=builder.Build();
238
238
host.Should().NotBeNull();
239
-
awaithost.Invoking(async x =>awaitx.RunCommandLineHostedAsync(TestContext.CancellationTokenSource.Token)).Should().ThrowAsync<InvalidOperationException>();
239
+
awaithost.Invoking(async x =>awaitx.RunCommandLineHostedAsync(TestContext.CancellationToken)).Should().ThrowAsync<InvalidOperationException>();
240
240
}
241
241
242
242
[TestMethod]
@@ -256,7 +256,7 @@ public async Task RunCommandLineHostedAsync_returning_result_of_ComplexArgAndOpt
0 commit comments