{"id":16270494,"url":"https://github.com/alexsjones/cli","last_synced_at":"2025-09-02T08:30:44.592Z","repository":{"id":144204953,"uuid":"95459393","full_name":"AlexsJones/cli","owner":"AlexsJones","description":"golang interactive cli with sub commands","archived":false,"fork":false,"pushed_at":"2023-11-06T08:11:27.000Z","size":727,"stargazers_count":34,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-16T00:51:48.532Z","etag":null,"topics":["cli","commandline","go","golang","prompt"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/AlexsJones.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":"2017-06-26T15:07:55.000Z","updated_at":"2024-10-19T15:30:02.000Z","dependencies_parsed_at":"2023-11-06T09:28:53.285Z","dependency_job_id":"0e705e24-aa6b-47a0-8706-17e9ca80c6a0","html_url":"https://github.com/AlexsJones/cli","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/AlexsJones%2Fcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexsJones%2Fcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexsJones%2Fcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexsJones%2Fcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexsJones","download_url":"https://codeload.github.com/AlexsJones/cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231742828,"owners_count":18419857,"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":["cli","commandline","go","golang","prompt"],"created_at":"2024-10-10T18:10:44.527Z","updated_at":"2024-12-29T17:11:45.739Z","avatar_url":"https://github.com/AlexsJones.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cli\n\n[![Build Status](https://travis-ci.org/AlexsJones/cli.svg?branch=master)](https://travis-ci.org/AlexsJones/cli)\n\n[![GoDoc](https://godoc.org/github.com/AlexsJones/cli/cli?status.svg)](https://godoc.org/github.com/AlexsJones/cli/cli)\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/3a06871c361d5e8e70ae/maintainability)](https://codeclimate.com/github/AlexsJones/cli/maintainability)\n\nThis is a simple interactive prompt for go that actually supports sub-commands, because I couldn't find one that did...\nSupports unlimited subcommand nesting.\n\nIt is ultra light weight and whilst is no where near as good as Cobra, it might be useful to someone.\n\nIt looks a bit like this (Once you wire up your commands: see example):\n```\n\u003e\u003e\u003egithub login auth alex\nHit auth\nAuthenticated with alex\n\n\u003e\u003e\u003egithub logout\nLogged out\n\n\u003e\u003e\u003ehelp\nnpm sub commands:\n\t[npm] file: relink an npm package locally\u003cprefix\u003e \u003cstring\u003e\n\t[npm] remove: remove a dep from package.json \u003cstring\u003e\n\t[npm] usage: find usage of a package within submodules \u003cstring\u003e\ngithub sub commands:\n\t[github] pr: pr command palette\n\t\t[pr] attach: attach the current issue to a pr \u003creponame\u003e \u003cowner\u003e \u003cprnumber\u003e\n\t[github] issue: Issue command palette\n\t\t[issue] set: set the current working issue \u003cissue url\u003e\n\t\t[issue] unset: unset the current working issue\n\t\t[issue] show: show the current working issue\n\t[github] login: use an access token to login to github\nsubmodule sub commands:\n\t[submodule] exec: execute in all submodules \u003ccommand string\u003e\n\n```\n\n\n# Installation\n\n```\ngo get github.com/AlexsJones/cli/cli\n```\n# Simple example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/AlexsJones/cli/cli\"\n\t\"github.com/AlexsJones/cli/command\"\n)\n\nfunc main() {\n\tc := cli.NewCli()\n\n\tc.AddCommand(command.Command{\n\t\tName: \"github\",\n\t\tHelp: \"github primary command interface\",\n\t\tFunc: func(args []string) {\n\t\t\tfmt.Println(\"I do nothing...\")\n\t\t},\n\t})\n\n\tc.Run()\n\n}\n```\n\nThis gives you something like:\n\n```\n\u003e\u003e\u003egithub\nI do nothing...\n\n```\n\n\n# Recursive subcommand example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/AlexsJones/cli/cli\"\n\t\"github.com/AlexsJones/cli/command\"\n)\n\nfunc main() {\n\tc := cli.NewCli()\n\n\tc.AddCommand(command.Command{\n\t\tName: \"github\",\n\t\tHelp: \"github primary command interface\",\n\t\tFunc: func(args []string) {\n\t\t\tfmt.Println(\"I do nothing...\")\n\t\t},\n\t\tSubCommands: []command.Command{\n\t\t\tcommand.Command{\n\t\t\t\tName: \"login\",\n\t\t\t\tHelp: \"access token to github\",\n\t\t\t\tFunc: func(args []string) {\n\t\t\t\t\tif len(args) == 0 {\n\t\t\t\t\t\tfmt.Println(\"Failed login\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tfmt.Printf(\"Logged in %s\", args[0])\n\t\t\t\t},\n\t\t\t\tSubCommands: []command.Command{\n\t\t\t\t\tcommand.Command{\n\t\t\t\t\t\tName: \"auth\",\n\t\t\t\t\t\tHelp: \"login sub command\",\n\t\t\t\t\t\tFunc: func(args []string) {\n\t\t\t\t\t\t\tfmt.Println(\"Hit auth\")\n\t\t\t\t\t\t\tif len(args) == 0 {\n\t\t\t\t\t\t\t\tfmt.Println(\"Failed login\")\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfmt.Printf(\"Authenticated with %s\\n\", args[0])\n\t\t\t\t\t\t},\n\t\t\t\t\t\tSubCommands: []command.Command{\n\t\t\t\t\t\t\tcommand.Command{\n\t\t\t\t\t\t\t\tName: \"sub\",\n\t\t\t\t\t\t\t\tHelp: \"login sub-sub command\",\n\t\t\t\t\t\t\t\tFunc: func(args []string) {\n\t\t\t\t\t\t\t\t\tif len(args) == 0 {\n\t\t\t\t\t\t\t\t\t\tfmt.Println(\"Failed login\")\n\t\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tfmt.Printf(\"Logged in with username %s\\n\", args[0])\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tcommand.Command{\n\t\t\t\tName: \"logout\",\n\t\t\t\tHelp: \"allows you to logout from github\",\n\t\t\t\tFunc: func(args []string) {\n\t\t\t\t\tfmt.Println(\"Logged out\")\n\t\t\t\t\tif len(args) == 0 {\n\t\t\t\t\t\tfmt.Println(\"Failed logout\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tfmt.Printf(\"Logged out with username %s\\n\", args[0])\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t})\n\tc.AddCommand(command.Command{\n\t\tName: \"sql\",\n\t\tHelp: \"sql primary command interface\",\n\t\tFunc: func(args []string) {\n\t\t\tfmt.Println(\"I do nothing...\")\n\t\t}})\n\tc.Run()\n```\n\n# System commands\n\n`help` \u0026 `exit`\n\nGives you information such as:\n\n```\n\u003e\u003e\u003ehelp\nnpm sub commands:\n\t[npm] file: relink an npm package locally\u003cprefix\u003e \u003cstring\u003e\n\t[npm] remove: remove a dep from package.json \u003cstring\u003e\n\t[npm] usage: find usage of a package within submodules \u003cstring\u003e\ngithub sub commands:\n\t[github] pr: pr command palette\n\t\t[pr] attach: attach the current issue to a pr \u003creponame\u003e \u003cowner\u003e \u003cprnumber\u003e\n\t[github] issue: Issue command palette\n\t\t[issue] set: set the current working issue \u003cissue url\u003e\n\t\t[issue] unset: unset the current working issue\n\t\t[issue] show: show the current working issue\n\t[github] login: use an access token to login to github\nsubmodule sub commands:\n\t[submodule] exec: execute in all submodules \u003ccommand string\u003e\n\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexsjones%2Fcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexsjones%2Fcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexsjones%2Fcli/lists"}