{"id":26291618,"url":"https://github.com/janpieterz/commandrunner","last_synced_at":"2025-05-08T01:41:52.154Z","repository":{"id":15701685,"uuid":"47322301","full_name":"janpieterz/CommandRunner","owner":"janpieterz","description":"A simple command runner to enable quick command line developer tools","archived":false,"fork":false,"pushed_at":"2022-05-18T14:30:00.000Z","size":1358,"stargazers_count":8,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-28T21:10:00.609Z","etag":null,"topics":["command-line","command-line-tool","csharp","terminal"],"latest_commit_sha":null,"homepage":null,"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/janpieterz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-03T09:38:56.000Z","updated_at":"2024-03-04T17:12:58.000Z","dependencies_parsed_at":"2022-08-30T18:11:41.229Z","dependency_job_id":null,"html_url":"https://github.com/janpieterz/CommandRunner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpieterz%2FCommandRunner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpieterz%2FCommandRunner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpieterz%2FCommandRunner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpieterz%2FCommandRunner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janpieterz","download_url":"https://codeload.github.com/janpieterz/CommandRunner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252983761,"owners_count":21835758,"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-tool","csharp","terminal"],"created_at":"2025-03-15T00:39:34.891Z","updated_at":"2025-05-08T01:41:52.126Z","avatar_url":"https://github.com/janpieterz.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CommandRunner\nA simple command runner to enable quick command line (developer) tools\n\n![demo](https://github.com/janpieterz/CommandRunner/blob/master/GifCommandRunner.gif)\n\n# Simple Usage\n```c#\nstatic void Main(string[] args)\n{\n\tRunnerConfiguration configuration = new RunnerConfiguration(\"Example Runner\");\n\tRunner.Start(configuration);\n}\n\npublic class EchoCommand \n{\n\n\t[Command(\"echo\", \"Echo back anything following the command.\")]\n\tpublic void Execute(List\u003cstring\u003e args)\n\t{\n\t\tforeach (var arg in args) Console.WriteLine(arg);\n\t}\n}\n\n[NestedCommand(\"nest\")]\npublic class NestingCommand\n{\n\t[Command(\"hello\", \"Say hello\")]\n\tpublic void Hello()\n\t{\n\t\tConsole.WriteLine(\"Hello\");\n\t}\n}\n```\nThe library accepts typed parameters and is able to easily setup a quick command line tool.\nThe library will try to map the arguments if it sees typed arguments. To prevent this, accept a list of strings in your method to parse it yourself, or no parameter at all if nothing is needed.\n\n# Attributes used to setup your runner(make sure to check the CoreconsoleTest app for examples):\n```c#\n[Command(string:identifier, string:help, bool:moveUpAfterSuccessfulExecution)]\n```\nThis attribute (used on methods) signals the runner it can run this method using the identifier. Can be used in a NestedCommand and a NavigatableCommand\n```c#\n[NestedCommand(\"pre-identifier\", \"help\")]\n```\nThis attribute, used on a class is more for easy prepending of all commands. All methods in the class that use the Command attribute will have their identifier prepended like: '{NestedIdentifier} {CommandIdentifier}'.\n```c#\n[NavigatableCommand(\"identifier\", \"help\")]\n```\nThis attribute, used on a class, signals a menu that can be used to navigate into. Child items won't be visible until navigated upon. If there is a multi-layer menu, the parent Menu class will be set on the child if there is a property of that type.\n```c#\n[NavigatableCommandAnnouncement]\n```\nThis attribute, used on a method, will be called in the terminal mode instead of displaying the identifier when navigated into the command.\n\n```c#\n[NavigatableCommandInitialization]\n```\nThis attribute, used on a method, will be called when navigating to a command. This can be used to setup the menu environment, for example an account menu with a specific account id to then only execute every method on this instance. The Initialize method is able to accept typed parameters like other command methods.\n\n\n# Settings\n\n## Using custom creator\n\n```c#\nprivate static void RunWithAutofacCreator()\n{\n\tvar container = CreateContainer();\n\tvar container = CreateContainer();\n\tRunnerConfiguration configuration = new RunnerConfiguration(\"Example Runner\");\n\tconfiguration.UseCommandActivator(type =\u003e container.Resolve(type));\n\tRunner.Start(configuration);\n}\n\nprivate static IContainer CreateContainer()\n{\n\tvar builder = new ContainerBuilder();\n\tbuilder.RegisterType\u003cEchoCommand\u003e().PropertiesAutowired();\n\tbuilder.RegisterType\u003cInjectable\u003e().PropertiesAutowired();\n\tbuilder.RegisterType\u003cNestingCommand\u003e().PropertiesAutowired();\n\treturn builder.Build();\n}\n```\n\n## Using provided assemblies\n\n```c#\nconfiguration.ScanAssemblies(new List\u003cAssembly\u003e() {typeof(EchoCommand).GetTypeInfo().Assembly});\n```\n\n## Using provided types\n\n```c#\nconfiguration.ScanTypes(new List\u003cType\u003e() {typeof(EchoCommand), typeof(AccountMenu)});\n```\n\n## Setting specific colors:\n```c#\nconfiguration.UseTerminalColor(ConsoleColor.DarkGreen);\nconfiguration.UseCommandColor(ConsoleColor.Yellow);\n```\n\n## Forcing mode\n```c#\nconfiguration.ForceTerminal();\nconfiguration.ForceCommandLine();\n```\n\n## Provide arguments (only applicable for command line mode)\n```c#\nconfiguration.UseArguments(new List\u003cstring\u003e() {\"test\", \"different\", \"arguments\"});\n```\n\n## Provide types to scan. These will be scanned for public methods and identified by PascalCasing or camelCasing splitting\n```c#\nconfiguration.AddTypes(new List\u003cType\u003e() { typeof(ExamplePublic) }, true);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanpieterz%2Fcommandrunner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanpieterz%2Fcommandrunner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanpieterz%2Fcommandrunner/lists"}