{"id":30450194,"url":"https://github.com/nochso/narg","last_synced_at":"2025-08-23T13:25:55.657Z","repository":{"id":57536892,"uuid":"84675724","full_name":"nochso/narg","owner":"nochso","description":null,"archived":false,"fork":false,"pushed_at":"2017-07-15T09:11:59.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T17:53:34.169Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nochso.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":"2017-03-11T19:48:53.000Z","updated_at":"2017-03-11T19:49:13.000Z","dependencies_parsed_at":"2022-08-29T00:40:51.840Z","dependency_job_id":null,"html_url":"https://github.com/nochso/narg","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nochso/narg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nochso%2Fnarg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nochso%2Fnarg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nochso%2Fnarg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nochso%2Fnarg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nochso","download_url":"https://codeload.github.com/nochso/narg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nochso%2Fnarg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271749048,"owners_count":24814115,"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-23T02:00:09.327Z","response_time":69,"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-08-23T13:25:54.103Z","updated_at":"2025-08-23T13:25:55.637Z","avatar_url":"https://github.com/nochso.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"narg - Nested arguments as configuration\n========================================\n\n[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![GitHub release](https://img.shields.io/github/release/nochso/narg.svg)](https://github.com/nochso/narg/releases)\n[![GoDoc](https://godoc.org/github.com/nochso/narg?status.svg)](http://godoc.org/github.com/nochso/narg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/nochso/narg)](https://goreportcard.com/report/github.com/nochso/narg)\n[![Build Status](https://travis-ci.org/nochso/narg.svg?branch=master)](https://travis-ci.org/nochso/narg)\n[![Coverage Status](https://coveralls.io/repos/github/nochso/narg/badge.svg?branch=master)](https://coveralls.io/github/nochso/narg?branch=master)\n\nInstallation\n------------\n\n    go get github.com/nochso/narg\n\n\nDocumentation\n-------------\n\nSee [godoc](https://godoc.org/github.com/nochso/narg) for API docs and examples.\n\n### Decoding configuration\n\nGiven a configuration struct consisting of scalar types, structs and slices:\n\n```go\ntype testConf struct {\n\tName   string\n\tPort   int\n\tDebug  bool\n\tFloat  float32\n\tHosts  []string\n\tPorts  []int\n\tPortsU []uint8\n\tAdmin  testUser\n\tUsers  []testUser\n}\n\ntype testUser struct {\n\tID   int    `narg:\"0\"`\n\tName string `narg:\"1\"`\n}\n```\n\nNote that users can be defined using positional arguments instead of named ones.\nThe order of the arguments is defined using the struct tag `narg` with the\nzero-based index (see testUser struct above).\n\nThe following narg input can be decoded into a pointer to `testConf`:\n\n```go\nin := `name foo\nport 80\ndebug 1\nfloat 3.14\nhosts a bee \"cee e\"\nports 1024 1025\nportsu 0xff 255\nadmin {\n\tid 1\n\tname \"Phil \\\"Tandy\\\" Miller\"\n}\nusers {\n\tid 2\n\tname \"Carol Pilbasian\"\n}\nusers 4 Todd`\ncfg := \u0026testConf{}\nerr := Decode(strings.NewReader(in), cfg)\n```\n\nField names are case-insensitive.\n\n`cfg` has now been populated with the given narg input:\n\n```go\ncfg = \u0026testConf{\n    Name:   \"foo\",\n    Port:   80,\n    Debug:  true,\n    Float:  3.14,\n    Hosts:  []string{\"a\", \"bee\", \"cee e\"},\n    Ports:  []int{1024, 1025},\n    PortsU: []uint8{0xff, 0xff},\n    Admin: testUser{\n        ID:   1,\n        Name: `Phil \"Tandy\" Miller`,\n    },\n    Users: []testUser{\n        {2, \"Carol Pilbasian\"},\n        {4, \"Todd\"},\n    },\n}\n```\n\nCurrently only supplied values are overwritten. You can set up your struct with\nsane defaults and when decoding a sparse config the defaults will be kept.\n\nLicense\n-------\n\nThis package is released under the [MIT license](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnochso%2Fnarg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnochso%2Fnarg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnochso%2Fnarg/lists"}