{"id":50549281,"url":"https://github.com/mzattahri/argv","last_synced_at":"2026-06-04T01:30:51.202Z","repository":{"id":349815622,"uuid":"1197788654","full_name":"mzattahri/argv","owner":"mzattahri","description":"A Go command-line library shaped like net/HTTP","archived":false,"fork":false,"pushed_at":"2026-05-01T16:06:37.000Z","size":381,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-01T18:12:38.344Z","etag":null,"topics":["cli","golang"],"latest_commit_sha":null,"homepage":"https://mz.attahri.com/code","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mzattahri.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-31T22:17:46.000Z","updated_at":"2026-05-01T16:06:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mzattahri/argv","commit_stats":null,"previous_names":["mzattahri/cli","mzattahri/argv"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/mzattahri/argv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzattahri%2Fargv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzattahri%2Fargv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzattahri%2Fargv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzattahri%2Fargv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mzattahri","download_url":"https://codeload.github.com/mzattahri/argv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzattahri%2Fargv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33886160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-03T02:00:06.370Z","response_time":59,"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":["cli","golang"],"created_at":"2026-06-04T01:30:49.395Z","updated_at":"2026-06-04T01:30:51.190Z","avatar_url":"https://github.com/mzattahri.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# argv\n\n[![Go Reference](https://pkg.go.dev/badge/mz.attahri.com/code/argv.svg)](https://pkg.go.dev/mz.attahri.com/code/argv)\n\n**`argv` treats the command line as a transport protocol.**\n\nPOSIX argv is a wire format: tokens in, structured input out. `argv` handles the\ntransport. The pipeline mirrors `net/http`; values are strings.\n\n## Quickstart\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"os\"\n\t\"os/signal\"\n\n\t\"mz.attahri.com/code/argv\"\n)\n\nfunc main() {\n\tctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)\n\tdefer stop()\n\n\tmux := \u0026argv.Mux{}\n\tmux.Flag(\"verbose\", \"v\", false, \"Verbose output\")\n\n\tgreet := \u0026argv.Command{\n\t\tDescription: \"Print a greeting\",\n\t\tRun: func(out *argv.Output, call *argv.Call) error {\n\t\t\t_, err := fmt.Fprintf(out.Stdout, \"hello %s\\n\", call.Args.Get(\"name\"))\n\t\t\treturn err\n\t\t},\n\t}\n\tgreet.Arg(\"name\", \"Who to greet\")\n\tmux.Handle(\"greet\", \"Say hello\", greet)\n\n\t(\u0026argv.Program{Summary: \"A demo CLI\"}).Run(ctx, mux, os.Args)\n}\n```\n\n```\n$ app greet gopher\nhello gopher\n```\n\n## Subcommands\n\n```go\nrepo := \u0026argv.Mux{}\nrepo.Handle(\"init\", \"Initialize a repository\", initCmd)\nrepo.Handle(\"clone\", \"Clone a repository\", cloneCmd)\nmux.Handle(\"repo\", \"Repository operations\", repo)\n```\n\n## Middleware\n\n```go\nvar WithAuth = argv.NewMiddleware(func(out *argv.Output, call *argv.Call, next argv.Runner) error {\n\tif err := checkAuth(call.Context()); err != nil {\n\t\treturn err\n\t}\n\treturn next.RunArgv(out, call)\n})\n\nmux.Handle(\"deploy\", \"Deploy\", WithAuth(WithLogging(deployCmd)))\n```\n\n## Environment fallback\n\n```go\nenvMW := argv.EnvMiddleware(map[string]string{\n\t\"verbose\": \"APP_VERBOSE\",\n\t\"host\":    \"APP_HOST\",\n}, nil)\nmux.Handle(\"deploy\", \"Deploy\", envMW(deployCmd))\n```\n\n## Tab completion\n\n```go\nmux.Handle(\"complete\", \"Output completions\", argv.CompletionCommand(mux))\n```\n\n## Introspection\n\n```go\nfor help, _ := range (\u0026argv.Program{}).Walk(\"app\", mux) {\n\tfmt.Printf(\"%s: %s\\n\", help.FullPath, help.Summary)\n}\n```\n\n## Testing\n\n```go\nimport \"mz.attahri.com/code/argv/argvtest\"\n\nrecorder := argvtest.NewRecorder()\ncall := argvtest.NewCall(\"greet gopher\")\nerr := mux.RunArgv(recorder.Output(), call)\n// recorder.Stdout() == \"hello gopher\\n\"\n```\n\nSee the [package documentation](https://pkg.go.dev/mz.attahri.com/code/argv) for\nthe full API and godoc examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmzattahri%2Fargv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmzattahri%2Fargv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmzattahri%2Fargv/lists"}