{"id":30385275,"url":"https://github.com/bruce-mig/cmd-parser","last_synced_at":"2025-08-21T02:11:45.230Z","repository":{"id":294954166,"uuid":"988618205","full_name":"bruce-mig/cmd-parser","owner":"bruce-mig","description":"cmd-parser is a C library that provides a Linux-like command-line interface (CLI) for custom C applications. ","archived":false,"fork":false,"pushed_at":"2025-05-22T20:20:11.000Z","size":164,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-22T21:59:54.021Z","etag":null,"topics":["c","c-library","cli","library"],"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/bruce-mig.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,"zenodo":null}},"created_at":"2025-05-22T20:18:56.000Z","updated_at":"2025-05-22T20:21:32.000Z","dependencies_parsed_at":"2025-05-26T05:03:23.440Z","dependency_job_id":null,"html_url":"https://github.com/bruce-mig/cmd-parser","commit_stats":null,"previous_names":["bruce-mig/cmd-parser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bruce-mig/cmd-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fcmd-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fcmd-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fcmd-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fcmd-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bruce-mig","download_url":"https://codeload.github.com/bruce-mig/cmd-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fcmd-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271415496,"owners_count":24755639,"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","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"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":["c","c-library","cli","library"],"created_at":"2025-08-21T02:11:40.444Z","updated_at":"2025-08-21T02:11:45.222Z","avatar_url":"https://github.com/bruce-mig.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cmd-parser\n\n**cmd-parser** is a C library that provides a Linux-like command-line interface (CLI) for custom C applications. It allows developers to easily integrate an interactive CLI into their applications, enabling users to execute commands and interact with the backend logic.\n\n## Features\n\n- **Custom Command Registration:** Developers can register their own commands and associated callbacks.\n- **Command Validation:** The library authenticates command formats and values before triggering callbacks.\n- **Built-in Commands:** Supports common commands such as `show`, `debug`, `clear`, and `config`.\n- **Command Negation:** Supports negation for `config` commands.\n- **Contextual Help:** Pressing `?` displays a list of valid next sub-options and help strings.\n- **Single Process Support:** The CLI currently supports one process at a time, communicating with the backend via callbacks.\n- **Extensible:** Future versions will support IPC between the CLI and backend processes.\n\n## Getting Started\n\n### Prerequisites\n\n- GCC or any standard C compiler\n- Make\n\n### Building the Library\n\n1. Run `make` to compile the library and example application.\n\n### Running the Example Application\n\n1. Execute the test application:\n   ```sh\n   ./exe\n   ```\n\n2. Interact with the CLI using the registered commands.\n\n## Usage\n- Include the following headers in your application:\n\n```bash\n#include \"libcli.h\"\n#include \"cmdtlv.h\"\n```\n- Link your application with the libcli.a library:\n\n```bash\ngcc your_app.c -lcli -o your_app\n```\n\nSee the provided Makefile for more details.\n\nRefer to `testapp.c` for a usage example.\n\n## Notes\n- The CLI library is designed to emulate the interactive shell found on routing devices.\n- Only one CLI process is supported at a time in the current version.\n\n\n## TODO\n- Add validation checks for supported data types.\n- Extend support for inter-process communication (IPC) between the CLI and backend.\n\n\u003c!-- For more detailed documentation, see the LinuxLikeCommandLineInterface.docx file included with the source code. --\u003e\n\n\n## Execution\n\nFrom the root of the project run `make` command.  \n\nThis will output the executable named `exe`.  \n\nRun the executable using the `./exe  command.  \n\nInside the REPL, input `.` to show the available commands.\n\n### Example Outputs\n\nShow Help\n\n```bash\nroot@cmd-parser\u003e $ show help\nParse Success.\nWelcome to Help Wizard\n========================\n1. Use '/' Character after the command to enter command mode\n2. Use '?' Character after the command to see possible follow up suboptions\n3. Use 'do' from within the config branch to directly trigger operational commands\n4. Use '.' Character after the command to see possible complete command completions\n5. Built-in commands:\n    a. cls - clear screen\n    b. cd - jump to top of cmd tree\n    c. cd.. - jump one level up of command tree\n    d. config [no] console name \u003cconsole name\u003e - set/unset new console name\n    e. config [no] supportsave enable - enable/disable supportsave facility\n    f. debug show cmdtree - Show entire command tree\n    g. show history - show history of commands triggered\n    h. repeat - repeat the last command\n                      Author : Bruce Migeri, Software Engineer\n                      Visit : github.com/bruce-mig for more projects\n\nroot@cmd-parser\u003e $\n```\n\nShow Available Commands\n\n```bash\nrun - 'show help' cmd to learn more\nroot@cmd-parser\u003e $ .\nParse Success.\nROOT show help\nROOT show history \u003cN\u003e\nROOT show history\nROOT show registered commands\nROOT show ip igmp configuration\nROOT show ip igmp groups vlan \u003cvlan-id\u003e\nROOT show ip igmp groups \u003cgroup-ip\u003e vlan \u003cvlan-id\u003e\nROOT show ip igmp groups \u003cgroup-ip\u003e\nROOT show ip igmp groups\nROOT debug ut \u003cut-enable\u003e\nROOT debug show cmdtree\nROOT config load \u003cfile-name\u003e\nROOT config supportsave enable\nROOT config console name \u003ccons-name\u003e\nROOT config router name \u003ccons-name\u003e\nROOT config mtrace source \u003csource-ip\u003e destination \u003cdestination-ip\u003e group \u003cgroup-ip\u003e\nROOT config mtrace source \u003csource-ip\u003e destination \u003cdestination-ip\u003e\nROOT config mtrace source \u003csource-ip\u003e group \u003cgroup-ip\u003e\nROOT config mtrace source \u003csource-ip\u003e\nROOT config\nROOT run term\nROOT run ut \u003cut-file-name\u003e \u003ctc-no\u003e\nROOT repeat\nROOT cls\nROOT cd..\nROOT cd\n```\n\nShow IPv4 IGMP groups per vLAN id\n\n```bash\nroot@cmd-parser\u003e $ show ip igmp groups 37 vlan 4005\nParse Success.\ncmd code = -1\ntlv-\u003eleaf_type = IPV4\ntlv-\u003eleaf_id   = group-ip\ntlv-\u003evalue     = 37\n\ntlv-\u003eleaf_type = INT\ntlv-\u003eleaf_id   = vlan-id\ntlv-\u003evalue     = 4005\n```\n\nConfig mtrace source and destination by group id\n\n\n```bash\nroot@cmd-parser\u003e $ config mtrace source 192.168.0.1 destination 172.16.0.1 group 37\nParse Success.\ncmd code = 3\ntlv-\u003eleaf_type = IPV4\ntlv-\u003eleaf_id   = source-ip\ntlv-\u003evalue     = 192.168.0.1\n\ntlv-\u003eleaf_type = IPV4\ntlv-\u003eleaf_id   = destination-ip\ntlv-\u003evalue     = 172.16.0.1\n\ntlv-\u003eleaf_type = IPV4\ntlv-\u003eleaf_id   = group-ip\ntlv-\u003evalue     = 37\n```\n\n\n\u003c!-- Copy the main*.c files up one directory level.\n\n```bash\n# Compile main*.c files\ngcc -g -c main1.c -o main1.o\n\n# Linking with libcli to create executable\ngcc -g main1.o -o main1.exe -L ./cmd-parser/ -lcli\n```\n\nThe first command compiles the `main1.c`to create object file `main1.o`. `–I` option tells compiler where to find header files included in `main1.c`.  \nThe second command links our project with libcli library and create final executable – `main1.exe`. You can run this executable and play around the same default commands implemented. Also, use show help to get yourself familiar with the CLI. Try out `“?”, “.”, “/”` features.  --\u003e\n\n\u003c!-- See the figure below. --\u003e\n\u003c!-- ![main1](static/image.png) --\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruce-mig%2Fcmd-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbruce-mig%2Fcmd-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruce-mig%2Fcmd-parser/lists"}