{"id":18785793,"url":"https://github.com/scott-the-programmer/cli.commandhandler","last_synced_at":"2025-06-22T11:36:57.303Z","repository":{"id":119522336,"uuid":"380662705","full_name":"scott-the-programmer/CLI.CommandHandler","owner":"scott-the-programmer","description":"An easy way to build map command models to their corresponding handlers","archived":false,"fork":false,"pushed_at":"2021-07-13T10:28:57.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-21T09:55:57.502Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scott-the-programmer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-27T05:56:30.000Z","updated_at":"2021-07-13T10:29:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe1b8002-ee9f-4c44-9d7c-6c59d99b00c9","html_url":"https://github.com/scott-the-programmer/CLI.CommandHandler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/scott-the-programmer/CLI.CommandHandler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scott-the-programmer%2FCLI.CommandHandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scott-the-programmer%2FCLI.CommandHandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scott-the-programmer%2FCLI.CommandHandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scott-the-programmer%2FCLI.CommandHandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scott-the-programmer","download_url":"https://codeload.github.com/scott-the-programmer/CLI.CommandHandler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scott-the-programmer%2FCLI.CommandHandler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261288983,"owners_count":23136044,"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":[],"created_at":"2024-11-07T20:49:40.699Z","updated_at":"2025-06-22T11:36:52.274Z","avatar_url":"https://github.com/scott-the-programmer.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLI.CommandHandler\n\n\u003ca href=\"https://codeclimate.com/github/scott-the-programmer/CLI.CommandHandler/maintainability\"\u003e\u003cimg src=\"https://api.codeclimate.com/v1/badges/96f8f4305388f7b0fc4a/maintainability\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://codeclimate.com/github/scott-the-programmer/CLI.CommandHandler/test_coverage\"\u003e\u003cimg src=\"https://api.codeclimate.com/v1/badges/96f8f4305388f7b0fc4a/test_coverage\" /\u003e\u003c/a\u003e\n\nThis is currently a WIP\n\n## Intent\n\nThis project aims to automatically map cli command models to corresponding command handlers. The overall goal is to eliminate manual command line arg parsing, and allow developers to focus on the logic.\n\nAt its current state, this project is highly coupled to https://github.com/commandlineparser/commandline\n\n## Example\n\n### Command Model\n\n```csharp\n    [Verb(\"make-noise\")]\n    public class MakeNoise : ICommand\n    {\n        [Option('n', \"noise\", Required = true, HelpText = \"Noise to emit\")]\n        public string Noise { get; set; }\n    }\n```\n\n### Command Handler\n\n```csharp\n    public class MakeNoiseCommand : ICommandHandler\u003cMakeNoise\u003e\n    {\n        public Task HandleAsync(MakeNoise command)\n        {\n            Console.WriteLine(command.Noise)\n            return Task.CompletedTask;\n        }\n    }\n```\n\n### Program.cs\n\n```csharp\n    public static void Main(string[] args)\n    {\n        var types = LoadRunCommands(); //TODO: Define this a bit better\n\n        Parser.Default.ParseArguments(args, types)\n            .WithParsed(Run);\n\n        Console.ReadLine();\n    }\n\n    public static void Run(object command)\n    {\n        var commandDispatcher = new CommandDispatcher(Assembly.GetExecutingAssembly().GetName());\n        commandDispatcher.DispatchAsync(command) //Run the MakeNoise command\n    }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscott-the-programmer%2Fcli.commandhandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscott-the-programmer%2Fcli.commandhandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscott-the-programmer%2Fcli.commandhandler/lists"}