{"id":16913690,"url":"https://github.com/pborman/options","last_synced_at":"2025-08-10T22:06:45.574Z","repository":{"id":57480883,"uuid":"142720647","full_name":"pborman/options","owner":"pborman","description":"Structured getopt processing for Go programs","archived":false,"fork":false,"pushed_at":"2023-12-22T02:14:13.000Z","size":78,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T16:21:23.532Z","etag":null,"topics":["getopt","go"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pborman.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-29T01:02:28.000Z","updated_at":"2023-02-16T06:19:54.000Z","dependencies_parsed_at":"2023-12-22T04:15:12.990Z","dependency_job_id":null,"html_url":"https://github.com/pborman/options","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/pborman/options","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pborman%2Foptions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pborman%2Foptions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pborman%2Foptions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pborman%2Foptions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pborman","download_url":"https://codeload.github.com/pborman/options/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pborman%2Foptions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269794097,"owners_count":24476743,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["getopt","go"],"created_at":"2024-10-13T19:14:43.660Z","updated_at":"2025-08-10T22:06:45.550Z","avatar_url":"https://github.com/pborman.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# options ![build status](https://travis-ci.org/pborman/options.svg?branch=master) [![GoDoc](https://godoc.org/github.com/pborman/options?status.svg)](http://godoc.org/github.com/pborman/options)\n\nStructured getopt processing for Go programs using the github.com/pborman/getopt/v2 package.\n\nThe options package makes adding getopt style command line options to Go programs as easy as declaring a structure:\n\n```\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/pborman/options\"\n)\n\nvar opts = struct {\n\tHelp    options.Help  `getopt:\"--help           display help\"`\n\tName    string        `getopt:\"--name=NAME      name of the widget\"`\n\tCount   int           `getopt:\"--count -c=COUNT number of widgets\"`\n\tVerbose bool          `getopt:\"-v               be verbose\"`\n\tN       int           `getopt:\"-n=NUMBER        set n to NUMBER\"`\n\tTimeout time.Duration `getopt:\"--timeout        duration of run\"`\n\tLazy    string\n}{\n\tName: \"gopher\",\n}\n\nfunc main() {\n\targs := options.RegisterAndParse(\u0026opts)\n\n\tif opts.Verbose {\n\t\tfmt.Printf(\"Command line parameters: %q\\n\", args)\n\t}\n\tfmt.Printf(\"Name: %s\\n\", opts.Name)\n}\n```\n\nThe options.Help type causes the command's usage to be displayed to standard error and the command to exit when the option is parsed from the command line.\n\nThe options package also supports reading options from file specified on the command line or an optional defaults file:\n\n```\npackage main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/pborman/options\"\n)\n\nvar opts = struct {\n\tFlags   options.Flags `getopt:\"--flags=PATH     read options from PATH\"`\n\tName    string        `getopt:\"--name=NAME      name of the widget\"`\n\tCount   int           `getopt:\"--count -c=COUNT number of widgets\"`\n\tVerbose bool          `getopt:\"-v               be verbose\"`\n\tN       int           `getopt:\"-n=NUMBER        set n to NUMBER\"`\n\tTimeout time.Duration `getopt:\"--timeout        duration of run\"`\n\tLazy    string\n}{\n\tName: \"gopher\",\n}\n\nfunc main() {\n\toptions.Register(\u0026opts)\n\t// read defaults from ~/.example.flags if the file exists.\n\tif err := opts.Flags.Set(\"?${HOME}/.example.flags\", nil); err != nil {\n\t\tfmt.Fprintln(os.Stderr, err)\n\t\tos.Exit(1)\n\t}\n\targs := options.Parse()\n\n\tif opts.Verbose {\n\t\tfmt.Printf(\"Command line parameters: %q\\n\", args)\n\t}\n\tfmt.Printf(\"Name: %s\\n\", opts.Name)\n}\n```\n\nUsing the following .example.flags file in your home directory that contains:\n\n```\nv = true\nname = \"github user\"\n```\n\nThe above program produces the following output:\n\n```\n$ go run x.go a parameter\nCommand line parameters: [\"a\" \"parameter\"]\nName: github user\n\n$ go run x.go --help     \nunknown option: --help\nUsage: x [-v] [-c COUNT] [--flags PATH] [--lazy value] [-n NUMBER] [--name NAME] [--timeout value] [parameters ...]\n -c, --count=COUNT  number of widgets\n     --flags=PATH   read options from PATH\n     --lazy=value   unspecified\n -n NUMBER          set n to NUMBER\n     --name=NAME    name of the widget [gopher]\n     --timeout=value\n                    duration of run\n -v                 be verbose\nexit status 1\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpborman%2Foptions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpborman%2Foptions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpborman%2Foptions/lists"}