{"id":13408148,"url":"https://github.com/fclp/fluent-command-line-parser","last_synced_at":"2025-12-17T14:47:25.523Z","repository":{"id":7061122,"uuid":"8344254","full_name":"fclp/fluent-command-line-parser","owner":"fclp","description":"A simple, strongly typed .NET C# command line parser library using a fluent easy to use interface","archived":false,"fork":false,"pushed_at":"2019-09-24T12:05:03.000Z","size":1125,"stargazers_count":538,"open_issues_count":55,"forks_count":85,"subscribers_count":30,"default_branch":"develop","last_synced_at":"2025-08-01T07:57:36.604Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fclp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-21T21:20:44.000Z","updated_at":"2025-07-07T15:39:27.000Z","dependencies_parsed_at":"2022-07-30T09:08:00.652Z","dependency_job_id":null,"html_url":"https://github.com/fclp/fluent-command-line-parser","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/fclp/fluent-command-line-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclp%2Ffluent-command-line-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclp%2Ffluent-command-line-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclp%2Ffluent-command-line-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclp%2Ffluent-command-line-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fclp","download_url":"https://codeload.github.com/fclp/fluent-command-line-parser/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fclp%2Ffluent-command-line-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27783856,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-17T02:00:08.291Z","response_time":55,"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":[],"created_at":"2024-07-30T20:00:51.047Z","updated_at":"2025-12-17T14:47:25.505Z","avatar_url":"https://github.com/fclp.png","language":"C#","readme":"Fluent Command Line Parser\r\n==========================\r\nA simple, strongly typed .NET C# command line parser library using a fluent easy to use interface.\r\n\r\n[![TeamCity Badge](https://img.shields.io/teamcity/http/teamcity.jetbrains.com/s/bt952.svg)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=bt952)\r\n[![Nuget Badge](https://img.shields.io/nuget/dt/FluentCommandLineParser.svg)](https://nuget.org/packages/FluentCommandLineParser)\r\n\r\n\t  \r\n### Download\r\n\r\nSee what's new in [v1.4.3](https://github.com/fclp/fluent-command-line-parser/wiki/Roadmap).\r\n\r\nYou can download the latest release from [CodeBetter's TeamCity server](http://teamcity.codebetter.com/project.html?projectId=project314)\r\n\r\nYou can also install using [NuGet](http://nuget.org/packages/FluentCommandLineParser/) via the command line\r\n```\r\ncmd\u003e nuget install FluentCommandLineParser\r\n```\r\nOr use the Package Manager console in Visual Studio:\r\n```\r\nPM\u003e Install-Package FluentCommandLineParser\r\n```\r\n### .:NEW:. Git like commands!\r\nCurrently in pre-release, see [this Stack Overflow](https://stackoverflow.com/questions/45289653/fluent-command-line-parser-call-function/47486943) post for example usage, and either use [this pre-release Nuget package](https://www.nuget.org/packages/FluentCommandLineParser/1.5.0.7-commands) or get the assemblies (including signed named assemblies) from the [latest build on teamcity.jetbrains.com](https://teamcity.jetbrains.com/viewLog.html?buildTypeId=FluentCommandLineParser_15preRelease\u0026buildId=lastSuccessful\u0026tab=artifacts)\r\n\r\n### Usage\r\n```csharp\r\nusing Fclp;\r\n\r\npublic class ApplicationArguments\r\n{\r\n   public int RecordId { get; set; }\r\n   public bool Silent { get; set; }\r\n   public string NewValue { get; set; }\r\n}\r\n\r\nstatic void Main(string[] args)\r\n{\r\n   // create a generic parser for the ApplicationArguments type\r\n   var p = new FluentCommandLineParser\u003cApplicationArguments\u003e();\r\n\r\n   // specify which property the value will be assigned too.\r\n   p.Setup(arg =\u003e arg.RecordId)\r\n    .As('r', \"record\") // define the short and long option name\r\n    .Required(); // using the standard fluent Api to declare this Option as required.\r\n\r\n   p.Setup(arg =\u003e arg.NewValue)\r\n    .As('v', \"value\")\r\n    .Required();\r\n\r\n   p.Setup(arg =\u003e arg.Silent)\r\n    .As('s', \"silent\")\r\n    .SetDefault(false); // use the standard fluent Api to define a default value if non is specified in the arguments\r\n\r\n   var result = p.Parse(args);\r\n\r\n   if(result.HasErrors == false)\r\n   {\r\n      // use the instantiated ApplicationArguments object from the Object property on the parser.\r\n      application.Run(p.Object);\r\n   }\r\n}\r\n```\r\n\r\nYou can also use the non-generic Fluent Command Line Parser to capture values without creating a container class.\r\n```csharp\r\nstatic void Main(string[] args)\r\n{\r\n  var p = new FluentCommandLineParser();\r\n\r\n  p.Setup\u003cint\u003e('r')\r\n   .Callback(record =\u003e RecordID = record)\r\n   .Required();\r\n\r\n  p.Setup\u003cstring\u003e('v')\r\n   .Callback(value =\u003e NewValue = value)\r\n   .Required();\r\n\r\n  p.Setup\u003cbool\u003e('s', \"silent\")\r\n   .Callback(silent =\u003e InSilentMode = silent)\r\n   .SetDefault(false);\r\n\r\n  p.Parse(args);\r\n}\r\n```\r\n### Parser Option Methods\r\n\r\n`.Setup\u003cint\u003e('r')` Setup an option using a short name, \r\n\r\n`.Setup\u003cint\u003e('r', \"record\")` or short and long name.\r\n\r\n`.Required()` Indicate the option is required and an error should be raised if it is not provided.\r\n\r\n`.Callback(val =\u003e Value = val)` Provide a delegate to call after the option has been parsed\r\n\r\n`.SetDefault(int.MaxValue)` Define a default value if the option was not specified in the args\r\n\r\n`.WithDescription(\"Execute operation in silent mode without feedback\")` Specify a help description for the option\r\n\r\n\r\n### Parsing To Collections\r\n\r\nMany arguments can be collected as part of a list. Types supported are `string`, `int32`, `int64`, `double`, `bool`, `Uri`, `DateTime` and `Enum`\r\n\r\nFor example arguments such as\r\n\r\n`--filenames C:\\file1.txt C:\\file2.txt \"C:\\other file.txt\"`\r\n\r\ncan be automatically parsed to a `List\u003cstring\u003e` using\r\n```csharp\r\nstatic void Main(string[] args)\r\n{\r\n   var p = new FluentCommandLineParser();\r\n\r\n   var filenames = new List\u003cstring\u003e();\r\n\r\n   p.Setup\u003cList\u003cstring\u003e\u003e('f', \"filenames\")\r\n    .Callback(items =\u003e filenames = items);\r\n\r\n   p.Parse(args);\r\n\r\n   Console.WriteLine(\"Input file names:\");\r\n\r\n   foreach (var filename in filenames)\r\n   {\r\n      Console.WriteLine(filename);\r\n   }\r\n}\r\n```\r\noutput:\r\n```\r\nInput file names\r\nC:\\file1.txt\r\nC:\\file2.txt\r\nC:\\other file.txt\r\n```\r\n### Enum support\r\nSince v1.2.3 enum types are now supported. \r\n```csharp\r\n[Flags]\r\nenum Direction\r\n{\r\n\tNorth = 1,\r\n\tEast = 2,\r\n\tSouth = 4,\r\n\tWest = 8,\r\n}\r\n```\r\n```csharp\r\np.Setup\u003cDirection\u003e(\"direction\")\r\n .Callback(d =\u003e direction = d);\r\n```\r\nTo specify 'East' direction either the text can be provided or the enum integer.\r\n```\r\ndosomething.exe --direction East\r\ndosomething.exe --direction 2\r\n```\r\n\r\nYou can also collect multiple Enum values into a `List\u003cTEnum\u003e`\r\n\r\n```csharp\r\nList\u003cDirection\u003e direction;\r\n\r\np.Setup\u003cList\u003cDirection\u003e\u003e('d', \"direction\")\r\n .Callback(d =\u003e direction = d);\r\n```\r\n\r\nFor example, specifiying 'South' and 'East' values\r\n```\r\ndosomething.exe --direction South East\r\ndosomething.exe --direction 4 2\r\n```\r\n\r\nSince v1.4 Enum Flags are also supported\r\n```csharp\r\nDirection direction;\r\n\r\np.Setup\u003cDirection\u003e(\"direction\")\r\n .Callback(d =\u003e direction = d);\r\n\r\np.Parse(args);\r\n\r\nAssert.IsFalse(direction.HasFlag(Direction.North));\r\nAssert.IsTrue(direction.HasFlag(Direction.East));\r\nAssert.IsTrue(direction.HasFlag(Direction.South));\r\nAssert.IsFalse(direction.HasFlag(Direction.West));\r\n```\r\n\r\nAnd the generic `FluentCommandLineParser\u003cT\u003e` (previously known as FluentCommandLineBuilder) also supports enums.\r\n\r\n```csharp\r\npublic class Args\r\n{\r\n   public Direction Direction { get;set; }\r\n   public List\u003cDirection\u003e Directions { get;set; }\r\n}\r\n```\r\n```csharp\r\nvar p = new FluentCommandLineParser\u003cArgs\u003e();\r\n\r\np.Setup(args =\u003e args.Direction)\r\n .As('d', \"direction\");\r\n\r\np.Setup(args =\u003e args.Directions)\r\n .As(\"directions\");\r\n```\r\nFrom v1.5 nullable enums are now supported.\r\n### Help Screen\r\nYou can setup any help arguments, such as -? or --help to print all parameters which have been setup, along with their descriptions to the console by using SetupHelp(params string[]).\r\n\r\nFor example:\r\n```csharp\r\n// sets up the parser to execute the callback when -? or --help is detected\r\nparser.SetupHelp(\"?\", \"help\")\r\n      .Callback(text =\u003e Console.WriteLine(text));\r\n```\r\nSince v1.4.1 you can also choose to display the formatted help screen text manually, so that you can display it under other circumstances.\r\n\r\n\r\nFor example:\r\n```csharp\r\nvar parser = new FluentCommandLineParser\u003cArgs\u003e();\r\n\t\r\nparser.SetupHelp(\"?\", \"help\")\r\n      .Callback(text =\u003e Console.WriteLine(text));\r\n\t\r\n// triggers the SetupHelp Callback which writes the text to the console\r\nparser.HelpOption.ShowHelp(parser.Options);\r\n```\r\n\r\n\r\n### Supported Syntax\r\n`[-|--|/][switch_name][=|:| ][value]`\r\n\r\nSupports boolean names\r\n```\r\nexample.exe -s  // enable\r\nexample.exe -s- // disabled\r\nexample.exe -s+ // enable\r\n```\r\nSupports combined (grouped) options\r\n```\r\nexample.exe -xyz  // enable option x, y and z\r\nexample.exe -xyz- // disable option x, y and z\r\nexample.exe -xyz+ // enable option x, y and z\r\n```\r\n### Development\r\nPlease feel free to provide any feedback on feature support or the Api itself.\r\n\r\nIf you would like to contribute, you may do so to the [develop branch](https://github.com/fclp/fluent-command-line-parser/tree/develop). Please contact me first if doing large scale changes.\r\n","funding_links":[],"categories":["CLI"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffclp%2Ffluent-command-line-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffclp%2Ffluent-command-line-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffclp%2Ffluent-command-line-parser/lists"}