{"id":37039972,"url":"https://github.com/espumita/dotnet-fluent-cli","last_synced_at":"2026-01-14T04:44:23.554Z","repository":{"id":115008974,"uuid":"455952885","full_name":"espumita/dotnet-fluent-cli","owner":"espumita","description":"Fluent interface to parse and configure arguments for command line applications in .NET.","archived":false,"fork":false,"pushed_at":"2023-11-15T22:51:44.000Z","size":153,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-23T08:10:36.086Z","etag":null,"topics":["args","command-line","dotnet","dotnet-core","fluent","parser"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/espumita.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-02-05T18:31:59.000Z","updated_at":"2022-03-08T23:45:49.000Z","dependencies_parsed_at":"2023-11-15T23:42:58.068Z","dependency_job_id":null,"html_url":"https://github.com/espumita/dotnet-fluent-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/espumita/dotnet-fluent-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espumita%2Fdotnet-fluent-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espumita%2Fdotnet-fluent-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espumita%2Fdotnet-fluent-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espumita%2Fdotnet-fluent-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/espumita","download_url":"https://codeload.github.com/espumita/dotnet-fluent-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/espumita%2Fdotnet-fluent-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28409847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["args","command-line","dotnet","dotnet-core","fluent","parser"],"created_at":"2026-01-14T04:44:22.727Z","updated_at":"2026-01-14T04:44:23.544Z","avatar_url":"https://github.com/espumita.png","language":"C#","readme":"# Fluent.Cli\n\nFluent interface to parse and configure arguments for command line applications in .NET.\n\n![NuGet](https://img.shields.io/nuget/v/Fluent.Cli.svg)\n\n## Types of standards supported\n\n* [POSIX](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html), UNIX  or  short-option like options, for example `ls -la ~/.docker` .\n* [GNU](https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html) like long options, for example `ls --all --show-control-chars ~/.docker` .\n* Traditional style options, for example `ls la ~/.docker` are not supported.\n* Java-like properties `-com.java.property` are not supported.\n* Windows-like options, for example `ls /all ~/.docker` are not supported.\n\n---\n\n## Usage\n`CliArgumentsBuilder` class lets you dynamically configure options and commands. Once built, it will parse the `string[] args` and return a `CliArguments` object.\n\n\n### Options:\n```c#\nvar cliArguments = CliArgumentsBuilder.With(args)\n    .Option('d')\n    .LongOption(\"debug\")\n    .Option('a', \"all\")\n    .Build();\n\nif (cliArguments.IsOptionPresent('d')) Console.WriteLine(\"Option 'd' enabled!\");\nif (cliArguments.IsOptionPresent('a')) Console.WriteLine(\"Option 'a' enabled!\");\nif (cliArguments.IsOptionPresent(\"all\")) Console.WriteLine(\"Option 'all' enabled!\");\nif (cliArguments.IsOptionPresent(\"debug\")) Console.WriteLine(\"Option 'debug' enabled!\");\n\n```\n### Commands:\n\n```c#\nvar cliArguments = CliArgumentsBuilder.With(args)\n    .Command(\"scan\")\n    .Command(\"login\")\n    .Build();\n\nif (cliArguments.IsCommandPresent()) {\n    var command = cliArguments.Command();\n    Console.WriteLine($\"Comand: {command.Name} selected!\");\n}\n```\n### Arguments:\n```c#\nvar cliArguments = CliArgumentsBuilder.With(args)\n    .Build();\n\nif (cliArguments.IsArgumentPresent(\"$0\")) {\n    var argument = cliArguments.Argument(\"$0\");\n    Console.WriteLine($\"Argument: {argument.Name} with value: {argument.Value}\")\n}\n```\n### Short/Long options with arguments:\n```c#\nvar cliArguments = CliArgumentsBuilder.With(args)\n    .LongOption(\"block-size\")\n        .WithArgument(\"SIZE\")\n    .Build();\n\nif (cliArguments.IsOptionPresent(\"block-size\")) {\n    var option = cliArguments.Option(\"block-size\");\n    if (option.IsArgumentPresent()) {\n        var argument = option.Argument();\n        Console.WriteLine($\"Option: {option.Name} enabled with {argument.Name} value: {argument.Value}\");\n    }\n}\n```\n\n---\n\n## Installation\n\nInstall [Fluent.Cli](https://www.nuget.org/packages/Fluent.Cli/) nuget package or:\n\nUsing dotnet cli:\n\n```\ndotnet add package Fluent.Cli\n```\n\nor using nuget Package Manager:\n\n```\nInstall-Package Fluent.Cli\n```\n\n---\n\n**Considerations**\n\n* You can get `string[] args` program's arguments directly the [Main entrypoint](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/main-command-line#:~:text=The%20Main%20method%20is%20the,point%20in%20a%20C%23%20program.), or just by calling `Environment.GetCommandLineArgs()`.\n\n* `-v`, `--version` and `--help` options are provided by default.\n\n* Prefixes can only be [Hyphen-minus](https://en.wikipedia.org/wiki/Hyphen-minus), `U+002D` character. One for sort options like `-c`, and two for long options like `--color`.\n\n* Other Dash like characters like: `U+2010`-`U+2015`-`U+2212`-`U+FE58`-`U+FE63`-`U+FF0D` are invalid dashs for options.\n\n* Only [unicode Basic Latin](https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)) alphanumeric upper and lowercase characters are accepted for short and long options: `-m`, `-2`, `-M`, `--mytest`, `--mytest01` or `--MyTest01` are valid options. Long options can also contain Hyphen-minus, U+002D character between words, for example: `--my-test-option`.\n\n* All controlled exceptions produced during the argument parsing step are considered as [ArgumentException](https://docs.microsoft.com/es-mx/dotnet/api/system.argumentexception?view=net-6.0). While all controlled exceptions produced during the builder configuration step are considered as `CliArgumentsBuilderConfigurationException`.\n\n## Under the dotnet Hood\n\n* This implementation assumes that program console arguments come directly splitted and without spaces, character U+0020 removed. This 'split' is built in at the assembly code of the  c++ language implementation, more info here: [Iso_C_1999, 5.1.2.2.1 Program startup](https://www.dii.uchile.cl/~daespino/files/Iso_C_1999_definition.pdf).\n\n* According to Microsoft [corerun.hpp](https://github.com/dotnet/runtime/blob/994d390c7cdc1f91b2b37235cf68605ead5d7c44/src/coreclr/hosts/corerun/corerun.hpp) source code, [native c++ main function](https://en.cppreference.com/w/cpp/language/main_function) is replaced by `wmain` from `Windows.h` when running in Windows and maintaining the native `main` in others cases like Linux.\n\n*  The C# implementation of the different [Main Entrypoints](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/main-command-line#:~:text=The%20Main%20method%20is%20the,point%20in%20a%20C%23%20program.), [GetCommandLineArgs](https://source.dot.net/System.Private.CoreLib/R/84c2c7cb5c89246f.html) and others. \n[System.Environment](https://source.dot.net/#System.Private.CoreLib/src/System/Environment.CoreCLR.cs,84c2c7cb5c89246f,references) make use of this pointer under the hood. \n\n* There are some Unicode checks at some points, but we can assume that all characters will be coded as two bytes in UTF-16 as C# native [System.String](https://docs.microsoft.com/en-US/dotnet/api/system.string?view=net-6.0).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fespumita%2Fdotnet-fluent-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fespumita%2Fdotnet-fluent-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fespumita%2Fdotnet-fluent-cli/lists"}