https://github.com/emptyflow/flowcommandline
Command line parser and processor
https://github.com/emptyflow/flowcommandline
command-line commandline parser
Last synced: 2 months ago
JSON representation
Command line parser and processor
- Host: GitHub
- URL: https://github.com/emptyflow/flowcommandline
- Owner: EmptyFlow
- License: mit
- Created: 2025-02-27T17:49:16.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-09-09T14:46:17.000Z (4 months ago)
- Last Synced: 2025-09-09T16:36:51.340Z (4 months ago)
- Topics: command-line, commandline, parser
- Language: C#
- Homepage:
- Size: 69.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/EmptyFlow/FlowCommandLine/actions/workflows/cipackage.yml) [](https://www.nuget.org/packages/FlowCommandLine)
# FlowCommandLine
FlowCommandLine is a C# library available on Nuget that is a fast and simple command line parser that works in two modes: command-based (e.g. `git commit ...`) or parameters-only. Parsing can be happened to any model class or record with parameterless constructor.
It support modern dotnet core runtimes (net8+), compilation in NativeAot. It supported auto documentation for commands and parameters.
Lot of types of properties [is supported](https://github.com/EmptyFlow/FlowCommandLine/wiki/Supported-mappings-types).
By default, the output will be to the system console, but can be redefined to any of your case - instead `CommandLine.Console ()` you can use `new CommandLine (new MyConsoleCommandLineProvider())` where `MyConsoleCommandLineProvider` it is you class which is implement `ICommandLineProvider` interface.
## Command-based mode
Example command line:
`myconapp runapp --param1=stringvalue --param2=120`
```csharp
public class Test {
public string Param1 { get; set; } = "";
public int Param2 { get; set; }
}
CommandLine.Console ()
// setup console application description version and so on
.Application ( "My Console App", "1.0.0", "full description.", "Copyright My Super Corporation", "myconapp" )
.AddCommand ( // add console command
"runapp", // command name
( Test parameters ) => { // command delegate handler for class Test
...
},
"Command description", // command description :)
new List { // adjust command parameters
FlowCommandParameter.CreateRequired("p1", "param1", "parameter 1 description"), // use factory methods for required parameter
FlowCommandParameter.CreateRequired("p3", "param3", "parameter 3 description"),
FlowCommandParameter.Create("p4", "param4", "parameter description"), // use factory method for non required parameter
FlowCommandParameter.Create("p2", "param2", "parameter2 description")
}
)
.RunCommand ();
```
## Parameters-only mode
Example command line:
`myconapp --param1=stringvalue --param2=120`
```csharp
var options = CommandLine.Console ()
.Application ( "My Console App", "1.0.0", "full description.", "Copyright My Super Corporation", "myconapp" )
.AddOption ( "p1", "param1", "parameter 1 description", required: true )
.AddOption ( "p2", "param2", "parameter 2 description", required: false )
.RunOptions (); // run options parse and
```