config

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: Apache-2.0 Imports: 6 Imported by: 3

README

🌳 Go YAML/JSON Configuration

Go Version GoDoc License

This config Bonzai branch is for safely managing any configuration as single, local YAML/JSON using industry standards for local configuration and system-safe writes. Use it to add a config subcommand to any other Bonzai command, or to your root Bonzai tree (z). All commands that use config that are composed into a single binary, no matter where in the tree, will use the same local config file even though the position within the file will be qualified by the tree location.

By default, importing config will assigned a new implementation of bonzai.Configurer to Z.Conf (satisfying any Z.Cmd requirement for configuration) and will use the name of the binary (Z.ExeName) as the directory name within os.UserConfDir with a config.yaml file name. To override this behavior, create a new pkd/config.Conf struct assign Id, Dir and File, and then assign that to Z.Conf.

Install

This command can be installed as a standalone program (for combined use with shell scripts perhaps) or composed into a Bonzai command tree.

Standalone

go install github.com/rwxrob/config/config@latest

Composed

package z

import (
	Z "github.com/rwxrob/bonzai"
	"github.com/rwxrob/config"
)

var Cmd = &bonzai.Cmd{
	Name:     `z`,
	Commands: []*Z.Cmd{help.Cmd, config.Cmd},
}

Note config is designed to be composed only in monolith mode (not multicall binary).

Tab Completion

To activate bash completion just use the complete -C option from your .bashrc or command line. There is no messy sourcing required. All the completion is done by the program itself.

complete -C config config

If you don't have bash or tab completion check use the shortcut commands instead.

Embedded Documentation

All documentation (like manual pages) has been embedded into the source code of the application. See the source or run the program with help to access it.

Design Considerations

  • JSON Output. JSON is YAML. But JSON is also much safer to deal with when parsing and piping into other things. The Query form has been modeled after jq (which has become something of a standard tool for mining information from configuration and other files.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &Z.Cmd{

	Name:      `config`,
	Summary:   `manage local YAML/JSON configuation`,
	Version:   `v0.4.3`,
	Copyright: `Copyright 2021 Robert S Muhlestein`,
	License:   `Apache-2.0`,
	Commands:  []*Z.Cmd{help.Cmd, data, _init, edit, _file, query},
	Description: `
		The *config* Bonzai branch is for safely managing any configuration
		as single, local YAML/JSON using industry standards for local
		configuration and persistence to a file using system-wide semaphores
		for safety. Use it to add a *config* subcommand to any other Bonzai
		command, or to your root Bonzai tree (*z*). Either way the same
		single configuration file is used, only the path within the
		configuration data is affected by the position of the *config*
		command.

		Querying configuration data can be easily accomplished with the
		*query* command that uses the same selection syntax as the *yq* Go
		utility (the same *yqlib* is used).

		All changes to configuration values are done via the *edit* command
		since configurations may be complex and deeply nested in some cases
		and promoting the automatic changing of configuration values opens
		the possibility that one buggy composed command might overwrite one
		or all the configurations for everything everything else composed
		into the binary.

		CAUTION: Take particular note that all commands composed into
		a single binary, no matter where in the tree, will use the same
		local config file even though the position within the file will be
		qualified by the tree location. Therefore, any composite command can
		read the configurations of any other composite command within the
		same binary. This is by design, but all commands composed together
		should always be vetted for safe practices. This is also the reason
		there commands like "config write" or "config set" will never be
		added.

		[The *cache* Bonzai branch is recommended when wanting to persist
		performant local data between command executions.]`,
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
Package config helps generically manage configuration data in YAML files (and, by extension JSON, which is a YAML subset) using the gopkg.in/yaml.v3 package (v2 is not compatible with encoding/json creating unexpected marshaling errors).
Package config helps generically manage configuration data in YAML files (and, by extension JSON, which is a YAML subset) using the gopkg.in/yaml.v3 package (v2 is not compatible with encoding/json creating unexpected marshaling errors).

Jump to

Keyboard shortcuts

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