viperbind

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2018 License: MIT Imports: 4 Imported by: 1

README

viperbind

viperbind auto-binds viper variables to cobra flags, and adds support for environment variables without requiring the tedious bindings.

It maps:

  • program dothis --flag -> PREFIX_DOTHIS_CMD_FLAG
  • program --threads=5 dothat thenthis -> PREFIX_GLOBAL_THREADS
  • program dothat thenthis --count=5 -> PREFIX_DOTHAT_THENTHIS_CMD_COUNT

And follows those rules:

  • start with the command prefix (often the same name as the root command), passed to AutoBind().
  • use the commands and subcommands, then append CMD (for Flags) or GLOBAL for PersistentFlags.
  • the root command doesn't have a command or subcommand and is therefore left without a command prefix (becomes PREFIX_GLOBAL... or PREFIX_CMD...)

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoBind

func AutoBind(root *cobra.Command, prefix string)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL