{"id":20446303,"url":"https://github.com/themalkolm/venom","last_synced_at":"2025-08-01T16:06:18.132Z","repository":{"id":144203907,"uuid":"83814629","full_name":"themalkolm/venom","owner":"themalkolm","description":"🐍 Make viper and cobra more venomous!","archived":false,"fork":false,"pushed_at":"2018-01-16T14:14:20.000Z","size":2152,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T08:45:50.347Z","etag":null,"topics":["12-factor","cobra","golang","viper"],"latest_commit_sha":null,"homepage":"","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/themalkolm.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}},"created_at":"2017-03-03T15:47:36.000Z","updated_at":"2020-12-15T12:25:36.000Z","dependencies_parsed_at":"2023-06-19T07:11:06.961Z","dependency_job_id":null,"html_url":"https://github.com/themalkolm/venom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/themalkolm/venom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themalkolm%2Fvenom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themalkolm%2Fvenom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themalkolm%2Fvenom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themalkolm%2Fvenom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/themalkolm","download_url":"https://codeload.github.com/themalkolm/venom/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themalkolm%2Fvenom/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268256820,"owners_count":24221051,"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-01T02:00:08.611Z","response_time":67,"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":["12-factor","cobra","golang","viper"],"created_at":"2024-11-15T10:19:08.206Z","updated_at":"2025-08-01T16:06:18.096Z","avatar_url":"https://github.com/themalkolm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# venom [![Build Status](https://travis-ci.org/themalkolm/venom.svg?branch=master)](https://travis-ci.org/themalkolm/venom)\n\nAdd some venom to make [cobra](https://github.com/spf13/cobra) and [viper](https://github.com/spf13/viper)\neven more dangerous!\n\n## Usage\n\nSee [_example](https://github.com/themalkolm/venom/tree/master/_example) folder for an example how to use venom. You can\nalso use it as a skeleton for any [12-factor](https://12factor.net) app you plan to use. It won't solve all problems but\nit will take care to solve the [config](https://12factor.net/config) one i.e. it will allow you to store your\nconfiguration in the environment variables.\n\nThe twist is that it doesn't *require* you to store all configuration in the environment variables. It is up to you to\ndefine how exactly you want to configure the application. It is even OK to mix however you want:\n\n* [cli flags](https://github.com/spf13/cobra#working-with-flags)\n* [config file/dir](https://github.com/spf13/viper#reading-config-files)\n* [environment variables](https://github.com/spf13/viper#working-with-flags)\n* [...](https://github.com/spf13/viper#what-is-viper)\n\n## Priority\n\nIf you use `TwelveFactorCmd` then here is the priority of resolution (highest to lowest):\n\n* `$ example --foo 42`\n* env as flags\n * `$ example -e EXAMPLE_FOO 42`\n * `$ example --env-file example.env # (assuming it has EXAMPLE_FOO=42 line)`\n* env as env\n * `$ EXAMPLE_ENV=EXAMPLE_FOO=42 ./bin/example`\n * `$ EXAMPLE_ENV_FILE=example.env ./bin/example`\n* `$ EXAMPLE_FOO=42 example`\n\nYou probably should not use env as env trick as it is very confusing for any user.\n\n## Autoflags\n\nIt is possible to ask venom to define flags for you. You need to provide a struct or pointer to struct that has\nspecial `flag` tag set e.g.\n\n```\ntype Config struct {\n\tFooMoo int `flag:\"foo-moo,m,Some mooness must be set\"`\n}\n```\n\nThis will allow venom to find this tag and parse long flag name, short flag name and the description. It expect you to\ndefine it as a comma separated triplet. It has some logic to deduce what you meant in case you have use only one or two\ncomma separated values.\n\nTo define flags you simply run `DefineFlags`. Note that in this case all flags will have default values set to zero values\nfor their types i.e. 0 for int, \"\" for string, false for bool etc.:\n\n```\nflags := venom.DefineFlags(Config{})\nRootCmd.PersistentFlags().AddFlagSet(flags)\n```\n\n## Defaults\n\nYou can not only define flags by a special struct but also the default values for these flags. Keep in mind that this\nworks for simple cases (int, unit, string, bool) and probably fails for the rest. It implements only a very minimal\nsubset of what pflags/cobra/viper are capable of - fix what you miss:\n\n```\ntype Config struct {\n\tFooMoo int `flag:\"foo-moo,m,Some mooness must be set\"`\n}\n```\n\nTo define default values simply override zero values:\n\n```\ndefaults := Config {\n    FooMoo: 42,\n}\nflags := venom.DefineFlags(defaults)\nRootCmd.PersistentFlags().AddFlagSet(flags)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthemalkolm%2Fvenom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthemalkolm%2Fvenom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthemalkolm%2Fvenom/lists"}