{"id":31809935,"url":"https://github.com/daishe/jsonflag","last_synced_at":"2026-07-02T10:31:41.526Z","repository":{"id":313667844,"uuid":"1052216107","full_name":"daishe/jsonflag","owner":"daishe","description":"A tiny Go library that can turn any struct into a command‑line flags","archived":false,"fork":false,"pushed_at":"2026-03-21T16:53:54.000Z","size":103,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-22T06:53:58.858Z","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/daishe.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":"2025-09-07T16:36:27.000Z","updated_at":"2026-03-21T16:53:58.000Z","dependencies_parsed_at":"2025-09-07T18:51:11.302Z","dependency_job_id":null,"html_url":"https://github.com/daishe/jsonflag","commit_stats":null,"previous_names":["daishe/jsonflag"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/daishe/jsonflag","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daishe%2Fjsonflag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daishe%2Fjsonflag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daishe%2Fjsonflag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daishe%2Fjsonflag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daishe","download_url":"https://codeload.github.com/daishe/jsonflag/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daishe%2Fjsonflag/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35043933,"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-07-02T02:00:06.368Z","response_time":173,"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":[],"created_at":"2025-10-11T05:56:07.965Z","updated_at":"2026-07-02T10:31:41.506Z","avatar_url":"https://github.com/daishe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsonflag\n\n**jsonflag** is a tiny Go library that can turn any JSON-marshallable struct into a set of command‑line flags. It works with the standard flag package and with the popular [pflag package](https://github.com/spf13/pflag), handling nested structs, slices, maps and pointer fields automatically.\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/daishe/jsonflag.svg)](https://pkg.go.dev/github.com/daishe/jsonflag)\n[![Go Report Card](https://goreportcard.com/badge/github.com/daishe/jsonflag)](https://goreportcard.com/report/github.com/daishe/jsonflag)\n\n## Adding to project\n\nFirst, use `go get` to download and add the latest version of the library to the project.\n\n```sh\ngo get -u github.com/daishe/jsonflag\n```\n\nThen include in your source code.\n\n```go\nimport \"github.com/daishe/jsonflag\"\n```\n\n## Usage example (with standard go `flag` package)\n\n```go\npackage main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/http/httputil\"\n\t\"net/url\"\n\t\"os\"\n\n\t\"github.com/daishe/jsonflag\"\n)\n\nfunc main() {\n\tconfig := struct {\n\t\tURL struct {\n\t\t\tScheme string `json:\"scheme\"`\n\t\t\tHost   string `json:\"host\"`\n\t\t\tPort   int    `json:\"port\"`\n\t\t\tPath   string `json:\"path\"`\n\t\t} `json:\"url\"`\n\t\tVerbose bool `json:\"verbose\"`\n\t}{}\n\n\t// default values\n\tconfig.URL.Scheme = \"https\"\n\tconfig.URL.Host = \"localhost\"\n\tconfig.URL.Port = 8080\n\n\tfs := flag.NewFlagSet(\"\", flag.ExitOnError) // you can also add it directly to the root flag set\n\tfor _, val := range jsonflag.Recursive(\u0026config) {\n\t\tfs.Var(val, jsonflag.JSONName(val.Path()), jsonflag.Usage(val.Path()))\n\t}\n\tif err := fs.Parse(os.Args[1:]); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Arguments parsing error: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\n\tu := url.URL{\n\t\tScheme: config.URL.Scheme,\n\t\tHost:   fmt.Sprintf(\"%s:%d\", config.URL.Host, config.URL.Port),\n\t\tPath:   config.URL.Path,\n\t}\n\n\tresp, err := http.Get(u.String())\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Doing request error: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\tdefer resp.Body.Close()\n\n\tif config.Verbose {\n\t\trespBytes, err := httputil.DumpResponse(resp, true)\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Dumping response error: %v\\n\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tfmt.Printf(\"%s\\n\", respBytes)\n\t}\n}\n```\n\n## License\n\nThe project is released under the **Apache License, Version 2.0**. See the full LICENSE file for the complete terms and conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaishe%2Fjsonflag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaishe%2Fjsonflag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaishe%2Fjsonflag/lists"}