{"id":22938418,"url":"https://github.com/jacraig/monarch","last_synced_at":"2025-08-12T18:33:21.478Z","repository":{"id":141486569,"uuid":"146921623","full_name":"JaCraig/Monarch","owner":"JaCraig","description":"A command line parser and command runner. In this you define a command and the input object. The library then parses the command line args, figures out which command to run, and then parses the data and places it in the input object. Comes with built in help and version info commands.","archived":false,"fork":false,"pushed_at":"2024-10-29T21:56:23.000Z","size":23314,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T23:44:32.193Z","etag":null,"topics":["command-line","command-line-parser","commandrunner"],"latest_commit_sha":null,"homepage":"https://jacraig.github.io/Monarch/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JaCraig.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-31T17:14:07.000Z","updated_at":"2024-10-29T21:56:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"d4f4fd05-0a95-4adf-8064-0c3d9253b21e","html_url":"https://github.com/JaCraig/Monarch","commit_stats":null,"previous_names":[],"tags_count":112,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FMonarch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FMonarch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FMonarch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaCraig%2FMonarch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JaCraig","download_url":"https://codeload.github.com/JaCraig/Monarch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229700206,"owners_count":18109935,"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","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":["command-line","command-line-parser","commandrunner"],"created_at":"2024-12-14T12:17:53.343Z","updated_at":"2024-12-14T12:17:53.901Z","avatar_url":"https://github.com/JaCraig.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monarch\n\n[![.NET Publish](https://github.com/JaCraig/Monarch/actions/workflows/dotnet-publish.yml/badge.svg)](https://github.com/JaCraig/Monarch/actions/workflows/dotnet-publish.yml) [![Coverage Status](https://coveralls.io/repos/github/JaCraig/Monarch/badge.svg?branch=master)](https://coveralls.io/github/JaCraig/Monarch?branch=master)\n\n\nMonarch is a command line parser/task runner.\n\n## Basic Usage\n\nIn order to use the system, you need to register it with your ServiceCollection:\n\n    serviceCollection.RegisterMonarch();\n\nOr if you are using [Canister](https://github.com/JaCraig/Canister):\n\n    serviceCollection.AddCanisterModules();\n\t\t\t\t\t\nThis is required prior to using the Monarch class for the first time. Once it is wired up, you can use the CommandRunner class:\n\n    var Instance = new CommandRunner();\n\treturn Instance.Run(args);\n\t\nThe CommandRunner class has a Run method which parses the args passed in and runs the appropriate command. The library has help and version commands built in to the system, however to create your own commands you need to create a command and also an input class:\n\n    public class TestCommand : CommandBaseClass\u003cTestInput\u003e\n    {\n        public override string[] Aliases =\u003e new string[] { \"Test\" };\n\n        public override string Description =\u003e \"Test command\";\n\n        public override string Name =\u003e \"Test Command\";\n\n        protected override async Task\u003cint\u003e Run(TestInput input)\n        {\n            await Task.CompletedTask;\n            Console.WriteLine(input.Value1);\n            Console.WriteLine(input.Value2);\n            Console.WriteLine(input.Value3.ToString(x =\u003e x));\n            return 0;\n        }\n    }\n\t\n\tpublic class TestInput\n    {\n        [Display(Description = \"Value 1 Property\")]\n        public int Value1 { get; set; }\n\n        [Display(Description = \"Value 2 Property\")]\n        public string Value2 { get; set; }\n\n        [Display(Description = \"Value 3 Property\")]\n        [MaxLength(3)]\n        public List\u003cstring\u003e Value3 { get; set; }\n    }\n\t\nThe command above inherits from the CommandBaseClass and defines the input that it expects. In this case TestInput. TestInput is how the command line arguments should be parsed by the system. The commands must define the aliases, description, and name for the command. The TestInput then defines properties and uses the DisplayAttribute from the System.ComponentModel.DataAnnotations namespace to define information. Also any data annotations defining max length, required, etc. are used to validate the input.\n\n## Options\n\nBy default the system does not require you to set options. However you can specify some options found within the system including command prefix, flag prefix, and indentation amount. In order to override what is in the system just create a class that inherits from IOptions:\n\n    public class DefaultOptions : IOptions\n    {\n        /// \u003csummary\u003e\n        /// Gets the command prefix.\n        /// \u003c/summary\u003e\n        /// \u003cvalue\u003eThe command prefix.\u003c/value\u003e\n        public string CommandPrefix { get; } = \"\";\n\n        /// \u003csummary\u003e\n        /// Gets the flag prefix.\n        /// \u003c/summary\u003e\n        /// \u003cvalue\u003eThe flag prefix.\u003c/value\u003e\n        public string FlagPrefix { get; } = \"-\";\n\n        /// \u003csummary\u003e\n        /// Gets the indent amount.\n        /// \u003c/summary\u003e\n        /// \u003cvalue\u003eThe indent amount.\u003c/value\u003e\n        public int IndentAmount { get; } = 4;\n    }","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacraig%2Fmonarch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacraig%2Fmonarch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacraig%2Fmonarch/lists"}