{"id":17787644,"url":"https://github.com/acim/act","last_synced_at":"2025-04-02T00:20:48.117Z","repository":{"id":196217224,"uuid":"694665553","full_name":"acim/act","owner":"acim","description":"Microservices oriented 12-factor Go library for parsing environment variables and command line flags to arbitrary config struct using struct tags","archived":false,"fork":false,"pushed_at":"2023-10-17T11:37:54.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-07T15:44:52.764Z","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/acim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2023-09-21T13:00:00.000Z","updated_at":"2023-09-21T13:01:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"2960b8f9-afcd-41e0-9ea5-76a16bb88597","html_url":"https://github.com/acim/act","commit_stats":null,"previous_names":["acim/act"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acim%2Fact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acim%2Fact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acim%2Fact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acim%2Fact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acim","download_url":"https://codeload.github.com/acim/act/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246731003,"owners_count":20824492,"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-10-27T10:12:08.686Z","updated_at":"2025-04-02T00:20:48.095Z","avatar_url":"https://github.com/acim.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# act\n\nMicroservices oriented [12-factor](https://12factor.net) Go library for parsing environment variables and\ncommand line flags to arbitrary config struct using struct tags to define default values and to override flag names and\nenvironment variables' names.\n\n[![Build Status](https://github.com/ectobit/act/workflows/build/badge.svg)](https://github.com/ectobit/act/actions)\n![Go Coverage](https://img.shields.io/badge/coverage-97.5%25-brightgreen?style=flat\u0026logo=go)\n[![Go Reference](https://pkg.go.dev/badge/go.acim.net/act.svg)](https://pkg.go.dev/go.acim.net/act)\n[![Go Report](https://goreportcard.com/badge/go.acim.net/act)](https://goreportcard.com/report/go.acim.net/act)\n\nThis package in intended to be used to parse command line arguments and environment variables into an arbitrary config struct.\nThis struct may contain multiple nested structs, they all will be processed recursively. Names of the flags and environment\nvariables are automatically generated. Flags will be kebab case of the field name eventually preceded by parent fields\nin case of nested structs. Names of environment variables will be similar, but additionally prefixed with command name\nand then snake and upper cased. Description of each flag will also be automatically generated in a human friendly way\nas much as possible. Additionally, you may override these auto-generated names using the struct tags and you also may\ndefine default value.\n\n- **flag** - override generated flag name\n- **env** - override generated environment variable name\n- **help** - override generated flag description\n- **def** - override default (zero) value\n\n## Important: all struct fields should be exported.\n\n## Custom flag types\n\nBesides the types supported by flag package, this package provides additional types:\n\n- **act.StringSlice** - doesn't support multiple flags but instead supports comma separated strings, i.e. \"foo,bar\"\n- **act.IntSlice** - doesn't support multiple flags but instead supports comma separated integers, i.e. \"5,-8,0\"\n- **act.URL**\n- **act.Time** - RFC3339 time\n\n## Order of precedence:\n\n- command line options\n- environment variables\n- default values\n\n## [Examples](example_test.go)\n\nRun `make test-verbose` to see examples output.\n\n## Subcommands\n\nThese are handled just like by standard library's flag package.\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"os\"\n\n\t\"go.acim.net/act\"\n)\n\nfunc main() {\n\tsubCmd := os.Args[1]\n\tswitch subCmd {\n\tcase \"create\":\n\t\tconfig := \u0026struct{}{}\n\t\tcreateCmd := act.New(\"create\")\n\n\t\tif err := createCmd.Parse(config, os.Args[2:]); err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\n\t\t// Implementation\n\n\tcase \"delete\":\n\t\tconfig := \u0026struct{}{}\n\t\tdeleteCmd := act.New(\"create\")\n\n\t\tif err := deleteCmd.Parse(config, os.Args[2:]); err != nil {\n\t\t\tlog.Println(err)\n\t\t}\n\n\t\t// Implementation\n\t}\n}\n```\n\n## TODO\n\n- support req struct tag to mark required values\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0\n  ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license\n  ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facim%2Fact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facim%2Fact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facim%2Fact/lists"}