Fixposition SDK 0.0.0-heads/main-0-g5c7edb5
Collection of c++ libraries and apps for use with Fixposition products on Linux
Loading...
Searching...
No Matches
yaml2shell

Overview

Tool to convert a yaml document to shell variables.

See Fixposition SDK: Build and installation on how to build and run the apps, or Fixposition SDK: Running pre-built apps on how to run the apps.

Command line help

yaml2shell (release, 0.0.0-heads/main-0-g5c7edb5)
Copyright (c) Fixposition AG (www.fixposition.com) and contributors
License: see the LICENSE files included in the source distribution
Utility to dump a yaml to shell variables, much like 'yq --output-format shell some.yaml'.
The output can be sourced in shell scripts or used as systemd EnvironmentFile.
Usage:
yaml2shell [flags] [<some.yaml]>
Where:
-h -- Print program help screen, and exit
-V -- Print program, version and license information, and exit
-v / -q -- Increase / decrease logging verbosity, multiple flags accumulate
-p <str> -- Prefix for variable names (default: none)
-o <file> -- Output to file instead of stdout
-u -- Uppercase variable names
-n <num> -- Maximum number of variables to output (default: 0, i.e. unlimited)
-s <size> -- Maximum size of output [bytes], 0 = unlimited (default: 1 MiB)
-f <re> -- Filter output (on variable name) using a regex, case insensitive unless uppercase
chars are used in the <re> string
If <some.yaml> is given the program reads the YAML from that file. Otherwise it processes YAML
from stdin. For example:
yaml2shell some.yaml
cat some.yaml | yaml2shell
Examle YAML input:
foo: 123
bar:
a: foo
b: false
empty:
xyz:
- 2
- 3
Output (default): (with '-p cfg_') (with '-p cfg -u') (with '-f ^(foo|empty) -u')
foo='123' cfg_foo='123' CFG_FOO='123' FOO='123'
bar_a='foo' cfg_bar_a='foo' CFG_BAR_A='foo' EMPTY=''
bar_b='false' cfg_bar_b='false' CFG_BAR_B='false'
empty='' cfg_empty='' CFG_EMPTY=''
xyz_0='2' cfg_xyz_0='2' CFG_XYZ_0='2'
xyz_1='3' cfg_xyz_1='3' CFG_XYZ_1='3'