{"id":25879488,"url":"https://github.com/yoz75/commandappinterface","last_synced_at":"2026-05-12T17:42:35.411Z","repository":{"id":280268542,"uuid":"941112485","full_name":"Yoz75/CommandAppInterface","owner":"Yoz75","description":"Small library for easy command interface creating","archived":false,"fork":false,"pushed_at":"2025-03-02T11:10:34.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-02T12:19:53.567Z","etag":null,"topics":["command-line","console","console-library","console-ui","csharp","csharp-library","dll","small-dll","small-library","terminal","terminal-ui"],"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/Yoz75.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2025-03-01T14:17:09.000Z","updated_at":"2025-03-02T11:10:37.000Z","dependencies_parsed_at":"2025-03-02T12:19:54.841Z","dependency_job_id":"5dc8510a-5c9b-4715-9dbd-4d292e2a6f69","html_url":"https://github.com/Yoz75/CommandAppInterface","commit_stats":null,"previous_names":["yoz75/commandappinterface"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoz75%2FCommandAppInterface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoz75%2FCommandAppInterface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoz75%2FCommandAppInterface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yoz75%2FCommandAppInterface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yoz75","download_url":"https://codeload.github.com/Yoz75/CommandAppInterface/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241509683,"owners_count":19974074,"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","console","console-library","console-ui","csharp","csharp-library","dll","small-dll","small-library","terminal","terminal-ui"],"created_at":"2025-03-02T13:18:49.710Z","updated_at":"2026-05-12T17:42:35.406Z","avatar_url":"https://github.com/Yoz75.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"NuGet: https://www.nuget.org/packages/CommandAppInterface/\n# Command App Interface\nThis is a library for easy command interface making (actualy I used something like this in my other projects, but I tired of always typing if/else):\u003cbr\u003e\n![изображение](https://github.com/user-attachments/assets/133b3b77-6dfe-4be3-999d-99cb4f648d72)\n(you can see this example in CAIExamples folder)\n\n## Usage:\nFirst you need to use CAI namespace and create CAI instance:\n```cs\nAppInterface interface = new(caiName: \"example\", isCatchExceptions: true);\n```\nIf you want to handle exceptions yourself, set isCatchExceptions false.\nNext to create a command, use AppInterface.AddCommand method:\n```cs\ninterface.AddCommand(new Command(\"command_name\", \"this is a command without parameters\", DoSomeDealMethod, \"this is text about how to use this command);\n\ninterface.AddCommand\u003cint\u003e(new Command(\"command_with_int_parameter\", \"this command expects an int parameter after command name\", MethodWithIntArgument, \"usage: \\\"command_with_int_parameter 42\\\"\"));\n```\nNow commands support up to 6 various parameters. Each parameters implements IParsable.\u003cbr\u003e\nIn the command constructor, the command handler method is assigned. It must have the same number of parameters and the same types as those specified in the command generics\u003cbr\u003e\n\nCAI supports commands with variable parameters count:\n```cs\ninterface.AddVariableArgsCommand\u003cdouble\u003e(\"command_with_many_double_parameters\". \"this command expects any count of doubles\", DoSomeDealWithDoubleArray, \"usage: \\\"command_with_many_double_parameters num1 num2 ... numN\\\"\")\n```\n\nTo start interface, run AppInterface.Start() method:\n```cs\ninterface.Start();\n```\nThe whole code looks like this:\n```cs\n...\nAppInterface interface = new(caiName: \"example\", isCatchExceptions: true);\n\ninterface.AddCommand(new Command(\"command_name\", \"this is a command without parameters\", DoSomeDealMethod, \"this is text about how to use this command);\ninterface.AddCommand\u003cint\u003e(new Command(\"command_with_int_parameter\", \"this command expects an int parameter after command name\", MethodWithIntArgument, \"usage: \\\"command_with_int_parameter 42\\\"\"));\ninterface.AddVariableArgsCommand\u003cdouble\u003e(\"command_with_many_double_parameters\". \"this command expects any count of doubles\", DoSomeDealWithDoubleArray, \"usage: \\\"command_with_many_double_parameters num1 num2 ... numN\\\"\")\n\ninterface.Start();\n...\n```\nAlso CAI contains built-in commands:\n![изображение](https://github.com/user-attachments/assets/77bf846e-32cb-4d41-8e87-5ada6e983405)\n\nYou can run one CAI inside other. In this case when you type quit, you will exit from internal CAI and continue working in external CAI:\n![изображение](https://github.com/user-attachments/assets/d8e47820-c742-4595-a31e-b49052516191)\n\n## Logging\nCAI can log your string message, or any Spectre.Console.Rendering.IRenderable:\u003cbr\u003e\n![изображение](https://github.com/user-attachments/assets/3d058d7e-bd5d-4dd2-97b4-7d9c4d3a52cb)\n\n\n## Styles\nCAI supports several styles:\n* None -- no welcome message and no command prompt\n* WriteCommandPrompt -- only command prompt\n* WelcomeMessage -- only welcome message\n* WelcomeAndCommandPrompt -- both command prompt and welcome message\n* CopyrightMessage -- Spectre.Console copyright\n* CAINAme -- show CAI name at start\n* Full -- standard CAI style. Contains everything\nthis way you can make clear interface without welcome message or blue command prompt:\n```cs\n            AppInterface clearInterface = new(\"clear interface\", isCatchExceptions: true, style: InterfaceStyles.None);\n```\n\"style\" parameter isn`t required, it is set to Styles.Full by default.\nStyles are presented enum with Flags attribute, so you can actually use WelcomeMessage | WriteCommandPromt instead of WelcomeAndCommandPrompt1.\n\n## Native AOT:\nCAI namespace itself supports Native AOT, also\nCAI uses [Spectre.Console](https://github.com/spectreconsole/spectre.console/)  (Not Spectre.Console.Cli!!!), as stated in https://spectreconsole.net/best-practices, Spectre.Console supports Native AOT.\nBut child namespaces doesn't have to support it.\n\n## Reflection:\n**WARNING: THIS NAMESPACE DOESN'T GUARANTEE NATIVE AOT SUPPORT!**\u003cbr\u003e\nusing namespace CAI.Reflection, you can add commands using attributes　（see CAI.Examples.ReflectionExample):\u003cbr\u003e\n```cs\n    [Command(\"reflection\", \"echo\", \"Echoes the input text\", \"echo [text]\")]\n    public static void Echo(string value)\n    {\n        AnsiConsole.WriteLine($\"{value}\");\n    }\n\n    [Command(\"reflection\", \"bar\", \"say bar\", \"bar\")]\n    public static void Bar()\n    {\n        AnsiConsole.WriteLine(\"bar\");\n    }\n```\nBy default, app interface doesn't load that commands, you have to call extension method AppInterface.LoadAttributedCommands()\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoz75%2Fcommandappinterface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoz75%2Fcommandappinterface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoz75%2Fcommandappinterface/lists"}