Top 1.6% dependent packages on proxy.golang.org
Top 1.5% dependent repos on proxy.golang.org
Top 3.8% forks on proxy.golang.org
proxy.golang.org : github.com/ardanlabs/conf/v2
Package conf provides support for using environmental variables and command line arguments for configuration. It is compatible with the GNU extensions to the POSIX recommendations for command-line options. See http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html There are no hard bindings for this package. This package takes a struct value and parses it for both the environment and flags. It supports several tags to customize the flag options. The field name and any parent struct name will be used for the long form of the command name unless the name is overridden. As an example, using this config struct: The following usage information would be output you can display. Usage: conf.test [options] [arguments] OPTIONS There is an API called Parse that can process a config struct with environment variable and command line flag overrides. There is also YAML support using the yaml package that is part of this modeule. There is a WithParse function that takes a slice of bytes containing the YAML or WithParseReader that takes any concrete value that knows how to Read. Additionally, if the config struct has a field of the slice type conf.Args then it will be populated with any remaining arguments from the command line after flags have been processed. For example a program with a config struct like this: If that program is executed from the command line like this: Then the cfg.Args field will contain the string values ["serve", "http"]. The Args type has a method Num for convenient access to these arguments such as this: You can add a version with a description by adding the Version type to your config type and set these values at run time for display.
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/ardanlabs/conf/v2
License: Apache-2.0
Latest release: over 3 years ago
First release: over 3 years ago
Namespace: github.com/ardanlabs/conf
Dependent packages: 11
Dependent repositories: 12
Stars: 169 on GitHub
Forks: 38 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 6 days ago