Skip to content

yaml get

William W. Kimball, Jr., MBA, MSIS edited this page Oct 10, 2020 · 13 revisions
  1. Introduction
  2. Self-Help Documentation

Introduction

The yaml-get command-line tool queries YAML/JSON/compatible data, returning the results to STDOUT. The input data can be read from a single file or STDIN (explicitly by using the - pseudo-file or implicitly by not providing a YAML_FILE positional argument while yaml-get is in a non-TTY session usually created by piping data into it via | or <<<). Results are printed one per line to simplify downstream parsing. Complex results (Hashes and Arrays) are rendered as JSON so they can also be printed one result per line. EYAML files can also be queried, returning decrypted results when the appropriate encryption keys are supplied.

This page explores the various command-line arguments understood by yaml-get. For real-world examples of using it, please check yaml-get Examples.

Self-Help Documentation

When the --help (-h) flag is passed into yaml-get, it produces this output:

usage: yaml-get [-h] [-V] -p YAML_PATH
                [-t ['.', '/', 'auto', 'dot', 'fslash']] [-S] [-x EYAML]
                [-r PRIVATEKEY] [-u PUBLICKEY] [-d | -v | -q]
                [YAML_FILE]

Retrieves one or more values from a YAML/JSON/Compatible file at a specified
YAML Path. Output is printed to STDOUT, one line per result. When a result is
a complex data-type (Array or Hash), a JSON dump is produced to represent it.
EYAML can be employed to decrypt the values.

positional arguments:
  YAML_FILE             the YAML file to query; use - to read from STDIN or
                        leave empty and send content via a non-TTY session

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -t ['.', '/', 'auto', 'dot', 'fslash'], --pathsep ['.', '/', 'auto', 'dot', 'fslash']
                        indicate which YAML Path seperator to use when
                        rendering results; default=dot
  -S, --nostdin         Do not implicitly read from STDIN, even when YAML_FILE
                        is not set and the session is non-TTY
  -d, --debug           output debugging details
  -v, --verbose         increase output verbosity
  -q, --quiet           suppress all output except errors

required settings:
  -p YAML_PATH, --query YAML_PATH
                        YAML Path to query

EYAML options:
  Left unset, the EYAML keys will default to your system or user defaults.
  Both keys must be set either here or in your system or user EYAML
  configuration file when using EYAML.

  -x EYAML, --eyaml EYAML
                        the eyaml binary to use when it isn't on the PATH
  -r PRIVATEKEY, --privatekey PRIVATEKEY
                        EYAML private key
  -u PUBLICKEY, --publickey PUBLICKEY
                        EYAML public key

For more information about YAML Paths, please visit
https://github.com/wwkimball/yamlpath.

Users instruct yaml-get where to find its results via the --query (-p) argument, which accepts a YAML Path. Should there be any issues automatically inferring the segment notation (dot [.] versus forward-slash [/]) used for this argument, the --pathsep (-t) argument can be used to force the notation.

Clone this wiki locally