{"id":23346654,"url":"https://github.com/drzymalanet/argparser","last_synced_at":"2025-04-07T17:22:07.113Z","repository":{"id":57602448,"uuid":"199478745","full_name":"drzymalanet/argparser","owner":"drzymalanet","description":"Multi-value argument parser for go programs","archived":false,"fork":false,"pushed_at":"2019-07-29T17:42:00.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T19:40:41.206Z","etag":null,"topics":[],"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/drzymalanet.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":"2019-07-29T15:25:52.000Z","updated_at":"2019-07-29T17:36:38.000Z","dependencies_parsed_at":"2022-09-26T20:01:02.409Z","dependency_job_id":null,"html_url":"https://github.com/drzymalanet/argparser","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drzymalanet%2Fargparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drzymalanet%2Fargparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drzymalanet%2Fargparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drzymalanet%2Fargparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drzymalanet","download_url":"https://codeload.github.com/drzymalanet/argparser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247694879,"owners_count":20980733,"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":[],"created_at":"2024-12-21T07:14:32.338Z","updated_at":"2025-04-07T17:22:07.079Z","avatar_url":"https://github.com/drzymalanet.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# argparser\nThis package allows for collecting more than one value for flag arguments. The standard `flags` package does not provide such capability.\n\n## Installation\n\n    go get github.com/drzymalanet/argparser\n\nAnd then\n\n    import \"github.com/drzymalanet/argparser\"\n\n## Quick manual\n\n1. Create parser with `NewParser(...)`,\n2. Parse the input arguments with `Parse(...)`,\n3. Check and get the flags with `Got(...)` and `Get(...)`.\n\n## Features\n\n### Easy to remember and simple to use\n\n\tfunc main() {\n\t\tparser := argparser.NewParser(\"--help\", \"--version\").Parse(os.Args[1:])\n\t\tif parser.Got(\"--help\") {\n\t\t\tlog.Fatal(\"Add help message here\")\n\t\t}\n\t\tif parser.Got(\"--version\") {\n\t\t\tlog.Fatal(\"Add version number here\")\n\t\t}\n\t\tfor _, arg := range parser.Get() {\n\t\t\tlog.Printf(\"Got argument: %s\", arg)\n\t\t}\n\t}\n\nResult:\n\n    $ app --version\n    2019/07/29 19:27:04 Add version number here\n\n### Allows for multi-value switches\n\nTo retrieve arguments such as in: `app --input a b c --output d e f`\n\n\tfunc main() {\n\t\tparser := argparser.NewParser(\"--input\", \"--output\").Parse(os.Args[1:])\n\t\tfor _, f := range parser.Get(\"--input\") {\n\t\t\tlog.Printf(\"Got input file: %s\", f)\n\t\t}\n\t\tfor _, f := range parser.Get(\"--output\") {\n\t\t\tlog.Printf(\"Got output file: %s\", f)\n\t\t}\n\t}\n\nResult:\n\n    $ app --input 1 2 3 --output a b c\n    2019/07/29 19:28:37 Got input file: 1\n    2019/07/29 19:28:37 Got input file: 2\n    2019/07/29 19:28:37 Got input file: 3\n    2019/07/29 19:28:37 Got output file: a\n    2019/07/29 19:28:37 Got output file: b\n    2019/07/29 19:28:37 Got output file: c\n\n### Works well in complex circumstances\n\nGiven a task to build a parser for something like this:\n\n    app a b c --input y1 y2 y3 --output x1 x2 -- u v w --input y4 y5\n\nWith the goal of parsing it to:\n - input flags: y1 y2 y3 y4 y5\n - output flags: x1 x2\n - and other args: a b c u v w\n \nThe code will look like:\n\n\tfunc main() {\n\t\toptions := []string{\"-i\", \"-o\", \"--input\", \"--output\", \"--help\", \"--\"}\n\t\tparser := argparser.NewParser(options...).Parse(os.Args[1:])\n\t\tfor _, f := range parser.Get(\"-i\", \"--input\") {\n\t\t\tlog.Printf(\"Got input file: %s\", f)\n\t\t}\n\t\tfor _, f := range parser.Get(\"-o\", \"--output\") {\n\t\t\tlog.Printf(\"Got output file: %s\", f)\n\t\t}\n\t\tfor _, tag := range parser.Get(\"\", \"--\") {\n\t\t\tlog.Printf(\"Found tag: %s\", tag)\n\t\t}\n\t}\n\nResult:\n\n\t$ app a b c --input y1 y2 y3 --output x1 x2 -- u v w --input y4 y5\n\t2019/07/29 19:16:56 Got input file: y1\n\t2019/07/29 19:16:56 Got input file: y2\n\t2019/07/29 19:16:56 Got input file: y3\n\t2019/07/29 19:16:56 Got input file: y4\n\t2019/07/29 19:16:56 Got input file: y5\n\t2019/07/29 19:16:56 Got output file: x1\n\t2019/07/29 19:16:56 Got output file: x2\n\t2019/07/29 19:16:56 Found tag: a\n\t2019/07/29 19:16:56 Found tag: b\n\t2019/07/29 19:16:56 Found tag: c\n\t2019/07/29 19:16:56 Found tag: u\n\t2019/07/29 19:16:56 Found tag: v\n\t2019/07/29 19:16:56 Found tag: w\n\n## Full documentation\nhttps://godoc.org/github.com/drzymalanet/argparser\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrzymalanet%2Fargparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrzymalanet%2Fargparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrzymalanet%2Fargparser/lists"}