{"id":13411090,"url":"https://github.com/schachmat/ingo","last_synced_at":"2025-10-29T11:57:20.688Z","repository":{"id":57486846,"uuid":"51270570","full_name":"schachmat/ingo","owner":"schachmat","description":"persistent storage for flags in go","archived":false,"fork":false,"pushed_at":"2017-04-03T01:15:10.000Z","size":19,"stargazers_count":38,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-25T04:09:48.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schachmat.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":"2016-02-07T22:57:40.000Z","updated_at":"2024-09-22T19:28:22.000Z","dependencies_parsed_at":"2022-09-01T22:51:36.892Z","dependency_job_id":null,"html_url":"https://github.com/schachmat/ingo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schachmat%2Fingo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schachmat%2Fingo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schachmat%2Fingo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schachmat%2Fingo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schachmat","download_url":"https://codeload.github.com/schachmat/ingo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243610788,"owners_count":20319028,"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-07-30T20:01:11.318Z","updated_at":"2025-10-29T11:57:15.653Z","avatar_url":"https://github.com/schachmat.png","language":"Go","readme":"[![Godoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/schachmat/ingo)\n[![Go Report Card](https://goreportcard.com/badge/schachmat/ingo)](https://goreportcard.com/report/schachmat/ingo)\n[![Coverage](https://gocover.io/_badge/github.com/schachmat/ingo)](https://gocover.io/github.com/schachmat/ingo)\n\n**ingo** is a simple Go library helping you to persist flags in a ini-like config\nfile.\n\n## Features and limitations\n\n* Requires Go 1.5 or later\n* automatically creates config file, if it does not exist yet\n* option value priorities (from high to low):\n  0. flags given on the commandline\n  0. flags read from the config file\n  0. defaults given when flags are initialized\n* write defaults to config file, if they are not set there already\n* every flag in the config file has the flag usage prepended as a comment\n* shorthand flags pointing to the same variable as another flag will not be\n  written to the config file to reduce noise. Both short and long version will\n  still show up in the `-h` output.\n* only rewrite the config file, when it would change\n* old flags, which are not used anymore are not removed\n* when old flags are found, a warning is printed to stderr (see example below)\n* flags must not contain the runes `:` and `=` and not start with `#` as these\n  runes are used as separators and comment prefix in the config file\n* no sections, namespaces or FlagSets other than the default one\n\n## Installation\n\n```shell\ngo get -u github.com/schachmat/ingo\n```\n\n## Usage example\n\nJust setup your flags with defaults like you are used to do. Instead of\n`flag.Parse()` you have to call `ingo.Parse(APPLICATION_NAME)` and check if an\nerror is returned. Thats all.\n\n```go\npackage main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"log\"\n\t\"github.com/schachmat/ingo\"\n)\n\nfunc main() {\n\tnum := flag.Int(\"num\", 3, \"`NUMBER` of times to\\n    \\tdo a barrel roll\")\n\tlocation := flag.String(\"location\", \"space\", \"`WHERE` to do the barrel roll\")\n\tflag.StringVar(location, \"l\", \"space\", \"`WHERE` to do the barrel roll (shorthand)\")\n\tif err := ingo.Parse(\"keep_rollin\"); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(*num, *location)\n}\n```\n\nThe (one newline, four spaces, one tab) separator will ensure that multi-line\nusage strings will be laid out correctly in the config file *and* in the `-h`\nhelp message. The code will create the following config file `.keep_rollinrc`\n(or any other location if specified in the environment variable\n`KEEP_ROLLINRC`):\n\n```shell\n# WHERE to do the barrel roll\nlocation=space\n\n# NUMBER of times to\n# do a barrel roll\nnum=3\n```\n\nIf you change num to 5 in the config file, it will be persistent on all future\nruns:\n\n```shell\n# WHERE to do the barrel roll\nlocation=space\n\n# NUMBER of times to\n# do a barrel roll\nnum=5\n```\n\nIf you add a new flag `style` to your programm, it will be added to the config\nfile on the first run using the default value from the flag:\n\n```shell\n# WHERE to do the barrel roll\nlocation=space\n\n# NUMBER of times to\n# do a barrel roll\nnum=5\n\n# HOW to do the barrel roll\nstyle=epic\n```\n\nIf you remove both location flags from your programm, the config entry will be\nrewritten to this:\n\n```shell\n# NUMBER of times to\n# do a barrel roll\nnum=5\n\n# HOW to do the barrel roll\nstyle=epic\n\n\n# The following options are probably deprecated and not used currently!\nlocation=space\n```\n\nAlso when such old flags are found, a warning like the following is printed to\nstderr when running `ingo.Parse`:\n\n```shell\n!!!!!!!!!!\n! WARNING: keep_rollin was probably updated,\n! Check and update .keep_rollinrc as necessary\n! and remove the last \"deprecated\" paragraph to disable this message!\n!!!!!!!!!!\n```\n\nAll config files will have a header like the following explaining the syntax:\n\n```shell\n# keep_rollin configuration\n#\n# This config has https://github.com/schachmat/ingo syntax.\n# Empty lines or lines starting with # will be ignored.\n# All other lines must look like \"KEY=VALUE\" (without the quotes).\n# The VALUE must not be enclosed in quotes as well!\n```\n\n## License - ISC\n\nCopyright (c) 2016-2017,  \u003cteichm@in.tum.de\u003e\n\nPermission to use, copy, modify, and/or distribute this software for any purpose\nwith or without fee is hereby granted, provided that the above copyright notice\nand this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\nOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\nTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n","funding_links":[],"categories":["配置","Configuration","配置管理 `配置解析库`","\u003cspan id=\"组态-configuration\"\u003e组态 Configuration\u003c/span\u003e","配置管理","Uncategorized"],"sub_categories":["标准CLI","Standard CLI","Advanced Console UIs","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","标准 CLI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschachmat%2Fingo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschachmat%2Fingo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschachmat%2Fingo/lists"}