{"id":17438613,"url":"https://github.com/blixt/go-group","last_synced_at":"2026-01-22T14:59:55.012Z","repository":{"id":137380274,"uuid":"66785693","full_name":"blixt/go-group","owner":"blixt","description":"Add command group support with flags package.","archived":false,"fork":false,"pushed_at":"2016-08-29T23:53:57.000Z","size":21,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T15:58:39.816Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/blixt/go-group","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/blixt.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":"2016-08-28T19:05:51.000Z","updated_at":"2019-12-05T20:21:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe48c64f-e9cb-4e5f-bf56-ed743155e3ae","html_url":"https://github.com/blixt/go-group","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/blixt/go-group","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fgo-group","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fgo-group/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fgo-group/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fgo-group/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blixt","download_url":"https://codeload.github.com/blixt/go-group/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fgo-group/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28664827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T14:01:31.714Z","status":"ssl_error","status_checked_at":"2026-01-22T13:59:23.143Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-10-17T12:38:31.090Z","updated_at":"2026-01-22T14:59:54.992Z","avatar_url":"https://github.com/blixt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"group package\n=============\n\n[![GoDoc](https://godoc.org/github.com/blixt/go-group?status.svg)](https://godoc.org/github.com/blixt/go-group)\n\nThe group package makes it easier to handle multiple command line groups\nwith the `flags` package.\n\n\nExample #1\n----------\n\n```go\npackage main\n\nimport \"fmt\"\nimport \"github.com/blixt/go-group\"\n\n// Keep references to sub-commands to parse arguments and flags later.\nvar help = group.Sub(\"help\")\nvar clone = group.Sub(\"clone\")\n\n// Each sub-command has its own FlagSet for specific flags.\nvar branch = clone.Flag.String(\"branch\", \"master\", \"The branch to clone\")\n\nfunc main() {\n\t// Parse the sub-command used (and any flags along the way).\n\tswitch group.Parse() {\n\tcase help:\n\t\tfmt.Println(\"This is some help for this tool.\")\n\tcase clone:\n\t\trepo := clone.Flag.Arg(0)\n\t\tif repo == \"\" {\n\t\t\tfmt.Println(\"Invalid repository!\")\n\t\t\tbreak\n\t\t}\n\t\tfmt.Printf(\"Cloning %s (branch %s)...\\n\", repo, *branch)\n\tdefault:\n\t\tfmt.Println(\"Unrecognized group. Choose one of:\", group.Subs())\n\t}\n}\n```\n\n### Result\n\n```\n$ ./example clone -branch dev git.example.com:myrepo.git\nCloning git.example.com:myrepo.git (branch dev)...\n\n$ ./example help\nThis is some help for this tool.\n```\n\n\nExample #2\n----------\n\nThis example shows how to make a deeply nested command and global flags.\n\n```go\npackage main\n\nimport \"fmt\"\nimport \"github.com/blixt/go-group\"\n\nvar preview = group.Sub(\"preview\")\nvar app = preview.Sub(\"app\")\nvar deploy = app.Sub(\"deploy\")\n\n// Global flag (before any of the command groups):\nvar verbose = group.Flag.Bool(\"v\", false, \"Output more\")\n\nfunc main() {\n\tswitch group.Parse() {\n\tcase deploy:\n\t\tfmt.Println(\"Deploying...\")\n\tdefault:\n\t\tfmt.Println(\"Unsupported command.\")\n\t}\n\n\tif *verbose {\n\t\tfmt.Println(\"And here's a bunch of extra output because you specified -v.\")\n\t}\n}\n```\n\n(When the `app` command group is no longer in preview, you would just\nneed to change `preview.Sub(\"app\")` to `group.Sub(\"app\")`.)\n\n### Result\n\n```\n$ ./example -v preview app deploy\nDeploying...\nAnd here's a bunch of extra output because you specified -v.\n\n$ ./example somethingelse\nUnsupported command.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblixt%2Fgo-group","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblixt%2Fgo-group","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblixt%2Fgo-group/lists"}