https://github.com/jaredreisinger/asp
asp, the Automatic Settings Provider, an opinionated companion for `viper` and `cobra`.
https://github.com/jaredreisinger/asp
12-factor cli cobra go viper
Last synced: 7 months ago
JSON representation
asp, the Automatic Settings Provider, an opinionated companion for `viper` and `cobra`.
- Host: GitHub
- URL: https://github.com/jaredreisinger/asp
- Owner: JaredReisinger
- License: isc
- Created: 2022-09-23T15:06:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-17T12:51:53.000Z (over 2 years ago)
- Last Synced: 2025-02-10T05:26:17.348Z (over 1 year ago)
- Topics: 12-factor, cli, cobra, go, viper
- Language: Go
- Homepage: https://pkg.go.dev/github.com/jaredreisinger/asp
- Size: 175 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# asp — Automatic Settings Processor
[](https://pkg.go.dev/github.com/jaredreisinger/asp)

[](https://github.com/jaredreisinger/asp/actions/workflows/pipeline.yaml)
[](https://codecov.io/gh/JaredReisinger/asp)
[](https://github.com/JaredReisinger/asp/blob/main/LICENSE)
`asp`, the Automatic Settings Provider, an opinionated companion for `viper` and `cobra`.
- [Getting started](https://github.com/JaredReisinger/asp/blob/main/docs/01-getting-started.md)
- [Config processing](https://github.com/JaredReisinger/asp/blob/main/docs/02-config-processing.md)
- [Defaults](https://github.com/JaredReisinger/asp/blob/main/docs/03-defaults.md)
- [Options](https://github.com/JaredReisinger/asp/blob/main/docs/04-options.md)
- [Config tags](https://github.com/JaredReisinger/asp/blob/main/docs/05-config-tags.md)
## Why does this exist?
The `cobra` package provides excellent command-line flag functionality, and `viper` provides a rich configuration store and environment variable binding… _but_… there’s a lot of boilerplate and redundant code if you want to achieve the nirvana of CLI flags and environment variables _and_ configuration file support for _**all**_ flags/settings in your application. The `asp` package attempts to reduce this boilerplate by capturing it all from your “canonical” configure structure definition.
The goals of `asp` are to
1. reduce the redundant boilerplate by concisely defining all of the necessary information in the config struct itself;
2. encourage good practices by ensuring that _every_ option has config, command-line _and_ environment variable representation;
3. avoid possible typos that using string-based configuration lookups can cause—Go can’t tell that `viper.Get("sommeSetting")` is misspelled at compile time—but it _can_ tell that `config.sommeSetting` is invalid if the struct defines the member as `config.someSetting`.