Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{ Array: true, Object: true, StringDQuote: true, StringSQuote: true, }
DefaultConfig is the default config with all parser features enabled.
var EnvConfig = Config{ Array: true, Object: false, StringDQuote: true, StringSQuote: true, }
EnvConfig is configuration for parser when the value comes from environmental variable.
var NoopConfig = Config{ Array: false, Object: false, StringDQuote: false, StringSQuote: false, IgnoreCommas: true, }
NoopConfig is configuration for parser that disables all options.
Functions ¶
func Value ¶
Value parses command line arguments, supporting boolean, numbers, strings, arrays, objects.
The parser implements a superset of JSON, but only a subset of YAML by allowing for arrays and objects having a trailing comma. In addition 3 string types are supported:
- single quoted string (no unescaping of any characters)
- double quoted strings (characters are escaped)
- strings without quotes. String parsing stops at special characters like '[]{},:'
In addition, top-level values can be separated by ',' to build arrays without having to use [].
func ValueWithConfig ¶
ValueWithConfig parses command line arguments, supporting boolean, numbers, strings, arrays, objects when enabled.
The parser implements a superset of JSON, but only a subset of YAML by allowing for arrays and objects having a trailing comma. In addition 3 string types are supported:
- single quoted string (no unescaping of any characters)
- double quoted strings (characters are escaped)
- strings without quotes. String parsing stops at special characters like '[]{},:'
In addition, top-level values can be separated by ',' to build arrays without having to use [].
Types ¶
type Config ¶
type Config struct { // Enables parsing arrays from values enclosed in []. Array bool // Enables parsing objects enclosed in {}. Object bool // Enables parsing double quoted strings, where values are escaped. StringDQuote bool // Enables parsing single quotes strings, where no values are escaped. StringSQuote bool // Enables ignoring commas as a shortcut for building arrays: a,b parses to [a,b]. // The comma array syntax is enabled by default for backwards compatibility. IgnoreCommas bool }
Config allows enabling and disabling parser features.