{"id":15067739,"url":"https://github.com/cosmictoast/libuconf","last_synced_at":"2026-02-24T21:33:13.761Z","repository":{"id":57508852,"uuid":"235833985","full_name":"CosmicToast/libuconf","owner":"CosmicToast","description":"Libuconf - your one stop shop for all your configuration needs.","archived":false,"fork":false,"pushed_at":"2020-05-03T13:29:11.000Z","size":55,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T13:39:07.061Z","etag":null,"topics":["configuration","flag","go","toml"],"latest_commit_sha":null,"homepage":"https://toast.cafe/x/libuconf","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CosmicToast.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-23T16:16:49.000Z","updated_at":"2020-05-03T13:29:13.000Z","dependencies_parsed_at":"2022-09-19T09:10:16.504Z","dependency_job_id":null,"html_url":"https://github.com/CosmicToast/libuconf","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/CosmicToast%2Flibuconf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CosmicToast%2Flibuconf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CosmicToast%2Flibuconf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CosmicToast%2Flibuconf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CosmicToast","download_url":"https://codeload.github.com/CosmicToast/libuconf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830912,"owners_count":20354850,"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":["configuration","flag","go","toml"],"created_at":"2024-09-25T01:26:55.101Z","updated_at":"2026-02-24T21:33:13.693Z","avatar_url":"https://github.com/CosmicToast.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"= libuconf: your one stop configuration shop\n\nLibuconf is a small go library to handle all sorts of configuration tasks.\nIt consists of three primary components:\n\n* an extendable scaffolding system for arbitrary configuration systems\n* several built-in systems\n* several built-in types implementing these systems\n\nIf this sounds confusing, don't worry!\nAs a user you don't need to worry about any of this.\nIf you're interested in the internals, head over to the \"READING\" file for a guided source-reading experience.\n\n== Basic Usage\nFirst, create an OptionSet - this is a set of options.\n[source, go]\n----\noptionset := \u0026libuconf.NewOptionSet(\"MyApp\")\n----\n\nThen, register some options - the API might remind you of go's built-in flag handling (that's on purpose).\n[source, go]\n----\nvar s1, s2, s3 *string\ns1 = optionset.String(\"myflag\", 0, \"initial value\", \"myflag help string\") \u003c1\u003e\noptionset.StringVar(s2, \"otherflag\", 'o', \"different value\", \"otherflag help string\") \u003c2\u003e\n\nopt, s3 := optionset.NewStringOpt(\"thirdflag\", 't', \"third value\", \"help string\") \u003c3\u003e\noptionset.Var(opt) \u003c4\u003e\n----\n\u003c1\u003e The 0 here is the null byte - if you set the short option to that, it's considered disabled.\n\u003c2\u003e In this example, you can configure s2 with command line flags using `--otherflag` or `-o`.\n\u003c3\u003e You can also create the underlying \"Option\" types.\n\u003c4\u003e If you do that, however, you must register them with your OptionSet separately!\n\nOnce you're done registering flags, you can parse things!\nThe built-in methods are ParseFlags, ParseEnv and ParseToml(File(s)|String).\nFurther invocations overwrite previous ones (see notes).\n[source, go]\n----\noptionset.ParseTomlFile(\"/etc/app.toml\")\noptionset.ParseTomlFile(\"~/.apprc\") \u003c1\u003e\noptionset.ParseEnv() \u003c2\u003e\nerr := optionset.ParseFlags(os.Args[1:]) \u003c3\u003e\nerr = optionset.Parse(os.Args[1:]) \u003c4\u003e\n----\n\u003c1\u003e If an option is set in both app.toml and .apprc, .apprc will take precedence because it was parsed afterwards.\n\u003c2\u003e With the default option types, as in this example, s1 will be configured by the MYAPP_MYFLAG environment variable.\n\u003c3\u003e All the Parse* functions actually return error - please check them!\n\u003c4\u003e Parse() will parse all of the standard files for your OS, followed by the environment, and finally the cli.\n\nThat's it, you're done, all your options should be set now.\n\n== Advanced Usage\nEvery parsing method (\"Env\", \"Flags\", \"Toml\") is associated with an interface: `EnvOpt`, `FlagOpt` and `TomlOpt` respectively.\nAll of these include the `Setter` interface, which defines the `Set(interface{}) error` function.\n\n`ParseEnv()` will look for environment variables that start with the capitalized contents of the OptionSet's application name, followed by an underscore and the output of `Env()` of each flag.\n`ParseToml*` will run the flag's `Toml()` output as a query against each TOML tree.\nFinally, `ParseFlags()` will look for long flags `Flag()` and short flags `ShortFlag()`.\n`Bool()` is needed for implicitly setting boolean flags on.\n`Usage()` consumes `AppName`, `Help()`, `Get()` and the two `Flag*` functions to generate a usage string - this means it shows you the \"current\" value in the help string, rather than the default you set.\n\nIf you want to add additional configuration sources (such as consul, for example), you would simply define a new interface that includes `Setter` and any functions you need.\nThen you would add a new `Parse*` function to `OptionSet` that includes a type assertion (or uses a new Visit* function).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmictoast%2Flibuconf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosmictoast%2Flibuconf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmictoast%2Flibuconf/lists"}