{"id":25249877,"url":"https://github.com/steverusso/goclap","last_synced_at":"2025-10-25T13:02:48.374Z","repository":{"id":65972522,"uuid":"603779095","full_name":"steverusso/goclap","owner":"steverusso","description":"Generate command line argument parsing code from Go comments.","archived":false,"fork":false,"pushed_at":"2024-09-30T13:11:47.000Z","size":155,"stargazers_count":9,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T00:52:46.029Z","etag":null,"topics":["cli","codegen","command-line","generator","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/steverusso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2023-02-19T14:55:59.000Z","updated_at":"2024-09-30T12:55:26.000Z","dependencies_parsed_at":"2024-04-20T15:45:59.657Z","dependency_job_id":"f5f3df98-3575-4d70-8509-ad5d607ae5c4","html_url":"https://github.com/steverusso/goclap","commit_stats":{"total_commits":116,"total_committers":2,"mean_commits":58.0,"dds":"0.025862068965517238","last_synced_commit":"97cf29d8ef032ba26b50e343d1d9ecb399fd98bc"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steverusso%2Fgoclap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steverusso%2Fgoclap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steverusso%2Fgoclap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steverusso%2Fgoclap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steverusso","download_url":"https://codeload.github.com/steverusso/goclap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238410501,"owners_count":19467413,"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","codegen","command-line","generator","go","golang"],"created_at":"2025-02-12T03:51:26.211Z","updated_at":"2025-10-25T13:02:48.252Z","avatar_url":"https://github.com/steverusso.png","language":"Go","readme":"# goclap\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/steverusso/goclap.svg)](https://pkg.go.dev/github.com/steverusso/goclap)\n[![GitHub CI](https://github.com/steverusso/goclap/actions/workflows/ci.yaml/badge.svg)](https://github.com/steverusso/goclap/actions/workflows/ci.yaml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/steverusso/goclap)](https://goreportcard.com/report/github.com/steverusso/goclap)\n\n```\ngo install github.com/steverusso/goclap@latest\n```\n\nA pre-build tool to generate **c**ommand **l**ine **a**rgument **p**arsing code from Go\ncomments. The idea is inspired by the [`clap` Rust\ncrate](https://github.com/clap-rs/clap), specifically its use of documentation and proc\nmacros.\n\n## Example\n\nThe following is taken from [`examples/simple/main.go`](./examples/simple/main.go).\n\n```go\n//go:generate goclap -type mycli\n\n...\n\n// Print a string with the option to make it uppercase.\ntype mycli struct {\n\t// Make the input string all uppercase.\n\t//\n\t// clap:opt upper\n\ttoUpper bool\n\t// The input string.\n\t//\n\t// clap:arg_required\n\tinput string\n}\n\nfunc main() {\n\tc := mycli{}\n\tc.Parse(os.Args[1:])\n\n\ts := c.input\n\tif c.toUpper {\n\t\ts = strings.ToUpper(s)\n\t}\n\n\tfmt.Println(s)\n}\n```\n\nBy running `go generate` (assuming `goclap` is installed), the `mycli` struct, its fields,\nand their comments will be used to generate code for parsing command line arguments into a\n`mycli`. That code will be placed in a file named `clap.gen.go` (see [the `simple`\nexample's one](./examples/simple/clap.gen.go)). The program can then be built with `go\nbuild`.\n\nRunning `./simple -u hello` will output \"HELLO\", and running `./simple -h` will output the\nfollowing help message:\n\n```\nsimple - Print a string with the option to make it uppercase\n\nusage:\n   simple [options] \u003cinput\u003e\n\noptions:\n   -upper   Make the input string all uppercase\n   -h       Show this help message\n\narguments:\n   \u003cinput\u003e   The input string\n```\n\n## Building\n\nTo just build the project as is, run `go build`. If you have\n[`task`](https://github.com/go-task/task) installed, you can run `task get-tools` to\ninstall the latest versions of\n([`goimports`](https://pkg.go.dev/golang.org/x/tools/cmd/goimports),\n[`gofumpt`](https://github.com/mvdan/gofumpt), and\n[`staticcheck`](https://staticcheck.io/)). Once you have those tools, you can run `task`\nto format, build, and lint the code, or you can run `task install` to format, lint, and\ninstall `goclap`.\n\n## Projects Using Goclap\n\n* [lockbook-x/lbcli](https://github.com/steverusso/lockbook-x/tree/master/lbcli)\n\n## License\n\nThis is free and unencumbered software released into the public domain. Please\nsee the [UNLICENSE](./UNLICENSE) file for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteverusso%2Fgoclap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteverusso%2Fgoclap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteverusso%2Fgoclap/lists"}