https://github.com/bartoszgolek/NFlags
Simple yet powerfull library to made parsing CLI arguments easy. Library also allow to print usage help "out of box".
https://github.com/bartoszgolek/NFlags
cli csharp helper library parser parsing
Last synced: 3 months ago
JSON representation
Simple yet powerfull library to made parsing CLI arguments easy. Library also allow to print usage help "out of box".
- Host: GitHub
- URL: https://github.com/bartoszgolek/NFlags
- Owner: bartoszgolek
- License: mit
- Created: 2017-10-31T20:25:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-12-20T08:31:22.000Z (over 3 years ago)
- Last Synced: 2024-09-30T20:47:43.032Z (9 months ago)
- Topics: cli, csharp, helper, library, parser, parsing
- Language: C#
- Homepage:
- Size: 277 KB
- Stars: 49
- Watchers: 6
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-dotnet-core - NFlags - Simple library to made parsing CLI arguments easy. Library also allow to print usage help "out of box". (Frameworks, Libraries and Tools / Misc)
- awesome-dotnet-core - NFlags - 解析CLI和开箱即用功能的库。 (框架, 库和工具 / 大杂烩)
- fucking-awesome-dotnet-core - NFlags - Simple library to made parsing CLI arguments easy. Library also allow to print usage help "out of box". (Frameworks, Libraries and Tools / Misc)
- awesome-dotnet-core - NFlags - Simple library to made parsing CLI arguments easy. Library also allow to print usage help "out of box". (Frameworks, Libraries and Tools / Misc)
README
# NFlags
[](https://travis-ci.org/bartoszgolek/NFlags)
[](https://www.nuget.org/packages/NFlags)
[](https://raw.githubusercontent.com/labstack/echo/master/LICENSE)Simple yet powerfull library to made parsing CLI arguments easy.
Library also allow to print usage help and application version "out of box".For example of usage check **Examples** directory.
## QuickStart
1. Install NFLags from NuGet.
1. Start new console project.
1. Configure NFLags:
```c#
Cli.Configure(configure => configure
.SetDialect(Dialect.Gnu)
.SetName("QuickStart")
.SetDescription("This is NFlags")
.EnableVersionOption()
)
.Root(rc => rc
.RegisterFlag("flag1", "f", "Flag description", false)
.RegisterOption("option", "o", "Option description", "optionDefaultValue")
.RegisterParameter("param", "Param description", "ParamDefaultValue")
.RegisterCommand("subcommand", "Subcommand Description", sc => sc
.SetExecute((commandArgs, output) => output.WriteLine("This is subcommand: " + commandArgs.GetParameter("SubParameter")))
.RegisterParameter("SubParameter", "SubParameter description", "SubParameterValue")
)
.RegisterParamSeries("paramSeries", "paramSeriesDescription")
.SetExecute((commandArgs, output) => output.WriteLine("This is root command: " + commandArgs.GetParameter("param")))
).
Run(args);
```
Run application and enjoy:
```
$> dotnet NFlags.QuickStart.dll
This is root command: ParamDefaultValue%
$> dotnet NFlags.QuickStart.dll xxx
This is root command: xxx
$> dotnet NFlags.QuickStart.dll --help
Usage:
QuickStart [COMMAND] [OPTIONS]... [PARAMETERS]...This is NFlags
Commands:
command Sub command DescriptionParameters:
Param description (Default: 'ParamDefaultValue')
paramSeriesDescriptionOptions:
--flag1, -f Flag description
--option , -o Option description (Default: 'optionDefaultValue')
--help, -h Prints this help
--version, -v Prints application version$> dotnet NFlags.QuickStart.dll subcommand
This is subcommand: SubParameterValue
$> dotnet NFlags.QuickStart.dll subcommand yyy
This is subcommand: yyy
$> dotnet NFlags.QuickStart.dll command --help
Usage:
QuickStart command [OPTIONS]... [PARAMETERS]...This is NFlags
Parameters:
Sub parameter description (Default: 'SubParameterValue')Options:
--help, -h Prints this help
--version, -v Prints application version$>
```
## Documentation
[See details on NFlags GitHub pages](https://bartoszgolek.github.io/NFlags/)