{"id":17102555,"url":"https://github.com/motemen/go-cli","last_synced_at":"2025-04-13T00:41:27.400Z","repository":{"id":29107820,"uuid":"32637324","full_name":"motemen/go-cli","owner":"motemen","description":"Yet another CLI app builder with commands, based on documentation.","archived":false,"fork":false,"pushed_at":"2018-01-18T15:48:32.000Z","size":20,"stargazers_count":31,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T18:43:44.185Z","etag":null,"topics":["cli","command-line","go"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Micke1101/OSTicket-plugin-TinyMCE","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/motemen.png","metadata":{"files":{"readme":"README.adoc","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}},"created_at":"2015-03-21T15:26:34.000Z","updated_at":"2025-02-04T03:20:34.000Z","dependencies_parsed_at":"2022-08-26T12:20:53.164Z","dependency_job_id":null,"html_url":"https://github.com/motemen/go-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/motemen%2Fgo-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motemen%2Fgo-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motemen%2Fgo-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motemen%2Fgo-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/motemen","download_url":"https://codeload.github.com/motemen/go-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650414,"owners_count":21139672,"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","command-line","go"],"created_at":"2024-10-14T15:29:22.344Z","updated_at":"2025-04-13T00:41:27.373Z","avatar_url":"https://github.com/motemen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"= go-cli image:https://travis-ci.org/motemen/go-cli.svg?branch=master[\"Build Status\", link=\"https://travis-ci.org/motemen/go-cli\"] image:http://godoc.org/github.com/motemen/go-cli?status.svg[\"GoDoc\", link=\"http://godoc.org/github.com/motemen/go-cli\"] image:http://gocover.io/_badge/github.com/motemen/go-cli[\"Test Coverage\", link=\"http://gocover.io/github.com/motemen/go-cli\"]\n\nYet another CLI app builder with commands, based on documentation.\n\n== Example\n\n[source,go]\n----\npackage main\n\nimport (\n    \"flag\"\n    \"os\"\n\n    \"github.com/motemen/go-cli\"\n)\n\nfunc main() {\n    cli.Use(\u0026cli.Command{\n        Name:  \"foo\",\n        Short: \"description in one line\",\n        Long: `foo [-v] \u003carg\u003e\n\nDescription in paragraphs, starting with a usage line.\nBlah blah blah`,\n        Action: func(flags *flag.FlagSet, args []string) error {\n            // Initialize and parse flags inside Action\n            verbose := flags.Bool(\"v\", false, \"set verbosity\")\n            flags.Parse(args)\n\n            args = flags.Args()\n            if len(args) \u003c 1 {\n                // Return cli.ErrUsage to show the command usage to the user\n                return cli.ErrUsage\n            }\n\n            ...\n\n            return nil\n        },\n    })\n    cli.Run(os.Args[1:])\n}\n----\n\nExample output:\n\n----\n% prog\nUsage: prog \u003ccommand\u003e [\u003cargs\u003e]\n\nCommands:\n    foo    description in one line\n----\n\n----\n% prog foo -h\nUsage: foo [-v] \u003carg\u003e\n\nDescription in paragraphs, starting with a usage line.\nBlah blah blah\n\nOptions:\n  -v=false: set verbosity\n----\n\n== Registering commands using documentation\n\nYou may use github.com/motemen/go-cli/gen to automatically register commands and\ntheir usages using comment documentation. An example documentation for the\nexample above:\n\n[source,go]\n----\n\n// +command foo - description in one line\n//\n//   foo [-v] \u003carg\u003e\n//\n// Description in paragraphs after a usage line.\n// Blah blah blah\nfunc actionFoo(flags *flag.FlagSet, args []string) error {\n    ...\n}\n----\n\nYou can use gen.Generate() to generate a source file like below:\n\n[source,go]\n----\n// auto-generated file\n\npackage main\n\nimport \"github.com/motemen/go-cli\"\n\nfunc init() {\n    cli.Use(\n        \u0026cli.Command{\n            Name:   \"foo\",\n            ...\n        },\n    )\n}\n----\n\nInclude this file to the build and you can maintain CLI commands using documentation. For complete example, refer to the _example directory.\n\n== Author\n\nmotemen \u003cmotemen@gmail.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmotemen%2Fgo-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmotemen%2Fgo-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmotemen%2Fgo-cli/lists"}