{"id":18858332,"url":"https://github.com/dmgk/getopt","last_synced_at":"2025-07-15T03:33:13.892Z","repository":{"id":57703940,"uuid":"496745990","full_name":"dmgk/getopt","owner":"dmgk","description":"Minimal, POSIX compatible argument parsing in Go","archived":false,"fork":false,"pushed_at":"2022-06-02T13:58:57.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T17:06:18.504Z","etag":null,"topics":["getopt","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmgk.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}},"created_at":"2022-05-26T19:23:31.000Z","updated_at":"2024-05-12T01:23:17.000Z","dependencies_parsed_at":"2022-09-02T12:10:21.381Z","dependency_job_id":null,"html_url":"https://github.com/dmgk/getopt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dmgk/getopt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmgk%2Fgetopt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmgk%2Fgetopt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmgk%2Fgetopt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmgk%2Fgetopt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmgk","download_url":"https://codeload.github.com/dmgk/getopt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmgk%2Fgetopt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265397582,"owners_count":23758444,"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":["getopt","golang"],"created_at":"2024-11-08T04:11:58.072Z","updated_at":"2025-07-15T03:33:13.842Z","avatar_url":"https://github.com/dmgk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## getopt\n\nPackage getopt provides a minimal, getopt(3)-like argument parsing implementation with POSIX compatible semantics.\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/dmgk/getopt.svg)](https://pkg.go.dev/github.com/dmgk/getopt)\n![Tests](https://github.com/dmgk/getopt/actions/workflows/tests.yml/badge.svg)\n\n#### Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/dmgk/getopt\"\n)\n\n// go run example.go -ba42 -v -z -- -w arg1 arg2\nfunc main() {\n\t// -a requires an argument\n\t// -b and -v have no arguments\n\t// -z may have an optional argument\n\topts, err := getopt.New(\"a:bz::v\")\n\tif err != nil {\n\t\tfmt.Printf(\"error creating scanner: %s\\n\", err)\n\t\treturn\n\t}\n\n\tfor opts.Scan() {\n\t\topt, err := opts.Option()\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"%s: error parsing option: %s\\n\", opts.ProgramName(), err)\n\t\t\tcontinue\n\t\t}\n\n\t\tif opt.HasArg() {\n\t\t\tfmt.Printf(\"%s: got option %q with arg %q\\n\", opts.ProgramName(), opt.Opt, opt)\n\t\t} else {\n\t\t\tfmt.Printf(\"%s: got option %q\\n\", opts.ProgramName(), opt.Opt)\n\t\t}\n\t}\n\n\tfmt.Printf(\"%s: remaining arguments: %v\\n\", opts.ProgramName(), opts.Args())\n}\n```\n\n```\n$ go run example.go -ba42 -v -z -- -w arg1 arg2\nexample: got option 'b'\nexample: got option 'a' with arg \"42\"\nexample: got option 'v'\nexample: got option 'z'\nexample: remaining arguments: [-w arg1 arg2]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmgk%2Fgetopt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmgk%2Fgetopt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmgk%2Fgetopt/lists"}