{"id":18655121,"url":"https://github.com/hmlendea/nucicli.menus","last_synced_at":"2026-07-02T20:34:04.110Z","repository":{"id":45384347,"uuid":"358520227","full_name":"hmlendea/nucicli.menus","owner":"hmlendea","description":"NuGet package for menu-based command-line interfaces","archived":false,"fork":false,"pushed_at":"2026-03-26T13:41:47.000Z","size":75,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-27T05:24:08.481Z","etag":null,"topics":["cli","command-line","console","console-application","dotnet","menu-system","nuget","nuget-package"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hmlendea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":null,"patreon":"hmlendea","open_collective":null,"ko_fi":"hmlendea","tidelift":null,"community_bridge":null,"liberapay":"HMlendea","issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"hmlendea","thanks_dev":null,"custom":"https://hmlendea.go.ro/fund.html"}},"created_at":"2021-04-16T07:54:21.000Z","updated_at":"2026-03-26T13:36:33.000Z","dependencies_parsed_at":"2025-06-25T10:34:52.722Z","dependency_job_id":null,"html_url":"https://github.com/hmlendea/nucicli.menus","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/hmlendea/nucicli.menus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmlendea%2Fnucicli.menus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmlendea%2Fnucicli.menus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmlendea%2Fnucicli.menus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmlendea%2Fnucicli.menus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmlendea","download_url":"https://codeload.github.com/hmlendea/nucicli.menus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmlendea%2Fnucicli.menus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35062689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"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":["cli","command-line","console","console-application","dotnet","menu-system","nuget","nuget-package"],"created_at":"2024-11-07T07:17:52.630Z","updated_at":"2026-07-02T20:34:04.102Z","avatar_url":"https://github.com/hmlendea.png","language":"C#","funding_links":["https://patreon.com/hmlendea","https://ko-fi.com/hmlendea","https://liberapay.com/HMlendea","https://buymeacoffee.com/hmlendea","https://hmlendea.go.ro/fund.html"],"categories":[],"sub_categories":[],"readme":"[![Donate](https://img.shields.io/badge/-%E2%99%A5%20Donate-%23ff69b4)](https://hmlendea.go.ro/fund.html) [![Build Status](https://github.com/hmlendea/nucicli.menus/actions/workflows/dotnet.yml/badge.svg)](https://github.com/hmlendea/nucicli.menus/actions/workflows/dotnet.yml) [![Latest GitHub release](https://img.shields.io/github/v/release/hmlendea/nucicli.menus)](https://github.com/hmlendea/nucicli.menus/releases/latest)\n\n# NuciCLI.Menus\n\n## About\n\n`NuciCLI.Menus` is a lightweight menu system for building interactive, command-driven console applications on top of [NuciCLI](https://github.com/hmlendea/nucicli).\n\nIt provides:\n\n- Structured menus with automatic `help` and `exit` commands\n- Hierarchical navigation (parent/child menus)\n- Command registration with descriptions\n- Optional command execution statistics\n- Simple lifecycle events for manager state changes\n\n## Contents\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [How It Works](#how-it-works)\n- [Public API Overview](#public-api-overview)\n- [Command Execution Statistics](#command-execution-statistics)\n- [Menu Navigation](#menu-navigation)\n- [Best Practices](#best-practices)\n- [Related Packages](#related-packages)\n- [License](#license)\n\n## Installation\n\n[![Get it from NuGet](https://raw.githubusercontent.com/hmlendea/readme-assets/master/badges/stores/nuget.png)](https://nuget.org/packages/NuciCLI.Menus)\n\n### .NET CLI\n\n```bash\ndotnet add package NuciCLI.Menus\n```\n\n### Package Manager\n\n```powershell\nInstall-Package NuciCLI.Menus\n```\n\n## Quick Start\n\nThe library is built around two core types:\n\n- `Menu`: defines commands and visual/menu behavior\n- `MenuManager`: opens menus, reads user input, and executes commands\n\nExample:\n\n```csharp\nusing NuciCLI.Menus;\n\npublic sealed class MainMenu : Menu\n{\n\tpublic MainMenu() : base(\"Main Menu\")\n\t{\n\t\tAddCommand(\"hello\", \"Print a greeting\", () =\u003e\n\t\t{\n\t\t\tNuciConsole.WriteLine(\"Hello from NuciCLI.Menus!\");\n\t\t});\n\n\t\tAddCommand(\"settings\", \"Open settings menu\", () =\u003e\n\t\t{\n\t\t\tMenuManager.Instance.OpenMenu\u003cSettingsMenu\u003e();\n\t\t});\n\t}\n}\n\npublic sealed class SettingsMenu : Menu\n{\n\tpublic SettingsMenu() : base(\"Settings\")\n\t{\n\t\tAddCommand(\"show\", \"Show current settings\", () =\u003e\n\t\t{\n\t\t\tNuciConsole.WriteLine(\"No settings configured yet.\");\n\t\t});\n\t}\n}\n\ninternal static class Program\n{\n\tprivate static void Main()\n\t{\n\t\tMenuManager.Instance.Start\u003cMainMenu\u003e();\n\t}\n}\n```\n\nRun the app and type:\n\n- `help` to list available commands in the current menu\n- `settings` to navigate to the child menu\n- `exit` to go back (or stop the app when at the root menu)\n\n## How It Works\n\nWhen a menu is created, two commands are added automatically:\n\n- `help`: prints all commands of the active menu\n- `exit`: closes the active menu\n\n`MenuManager` manages the active menu loop:\n\n1. Prints the menu header and command list\n2. Reads user input using the active menu prompt\n3. Resolves the command name and executes its action\n4. Prints optional execution statistics (if enabled)\n5. Repeats until the root menu is closed\n\nIf a command is unknown, the user gets an `Unknown command` message.\n\n## Public API Overview\n\n### `Menu`\n\nMain customization points:\n\n- `Title`: visible menu title\n- `TitleDecoration`: decoration text around title (default: `-==\u003c `)\n- `Prompt`: command input prompt (default: `\u003e `)\n- `TitleColour`, `TitleDecorationColour`, `PromptColour`: console colors\n\nMain methods:\n\n- `AddCommand(string name, string description, Action action)`\n- `Exit()`\n\nEvents:\n\n- `Created`\n- `Disposed`\n\n### `MenuManager`\n\nSingleton access:\n\n- `MenuManager.Instance`\n\nCore methods:\n\n- `Start\u003cTMenu\u003e()`\n- `Start\u003cTMenu\u003e(params object[] parameters)`\n- `OpenMenu\u003cTMenu\u003e()`\n- `OpenMenu\u003cTMenu\u003e(params object[] parameters)`\n- `OpenMenu(Type menuType, params object[] parameters)`\n- `CloseMenu()` / `CloseMenu(string menuId)`\n- `SwitchToMenu(string menuId)`\n\nState and configuration:\n\n- `ActiveMenuId`\n- `IsRunning`\n- `AreStatisticsEnabled`\n\nEvents:\n\n- `Starting`\n- `Started`\n- `Stopped`\n- `ActiveMenuChanged`\n\n## Command Execution Statistics\n\nSet `MenuManager.Instance.AreStatisticsEnabled = true` to print command execution results:\n\n- Status: `Success`, `Failed`, or `Cancelled`\n- Duration in seconds/minutes\n- Error message for failed commands\n\n`InputCancellationException` is treated as `Cancelled` when thrown during command execution.\n\n## Menu Navigation\n\nOpening a menu from another menu creates a parent-child relation internally.\n\n- `OpenMenu\u003cTChild\u003e()` moves focus to the child menu\n- `exit` in the child menu returns to the parent menu\n- `exit` in the root menu stops the manager loop\n\nThis makes it straightforward to model multi-level CLI applications.\n\n## Best Practices\n\n- Keep command names short, lower-case, and verb-oriented (`list`, `create`, `sync`)\n- Use command descriptions as concise help text\n- Organize features into focused submenus\n- Enable statistics in development and troubleshooting workflows\n- Handle expected input cancellation in command actions where relevant\n\n## Related Packages\n\nThe NuciCLI ecosystem is split into focused packages:\n\n- [NuciCLI](https://github.com/hmlendea/nucicli) for core console helpers\n- [NuciCLI.Arguments](https://github.com/hmlendea/nucicli.arguments) for command-line argument handling\n- [NuciCLI.Menus](https://github.com/hmlendea/nucicli.menus) for interactive terminal menus\n\n## Target Framework\n\nThe current package targets `.NET 10.0`.\n\n## License\n\nThis project is licensed under the `GNU General Public License v3.0` or later. See [LICENSE](./LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmlendea%2Fnucicli.menus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmlendea%2Fnucicli.menus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmlendea%2Fnucicli.menus/lists"}