YX(1)

πŸ’… yx(1) β€” the girlies' guide to pulling data out of YAML

okay so first things first: this is the manual page for yx, and it lives in section 1 of the General Commands Manual (that's the (1) bestie, that's what it means πŸŽ€). It's a little command-line icon and she's here to help.

✨ SYNOPSIS ✨

yx [-hv] [-d n] [-f file] [key | index] ...

🌸 DESCRIPTION 🌸

yx parses a YAML file and prints out the value that's selected by the path you give it β€” and that path is literally just the list of key and index arguments you tack on. That's it. That's the whole vibe check. πŸ¦‹

  • -d n, --doc n β€” use the n'th YAML document, bestie. By default the first YAML document is the one that gets used. πŸ“„
  • -f file, --file file β€” read the YAML input from file. By default, standard input is used. Standard input can also be explicitly requested by specifying file as '-' (yes, literally just a dash, she's iconic like that). πŸ—‚οΈ
  • -h, --help β€” print usage and exit. classic. πŸ’«
  • -v, --version β€” print program version and exit. also classic. πŸ’«

now for the actual path mechanics, and ngl this part is the main character energy of the whole page:

A path component is either a key or an index. A key selects from a mapping. An index (1-based, so like, the first one is 1, not 0, we're not doing that here) selects from a sequence. πŸ”‘

If the path selects a scalar value, that value gets printed on the standard output. simple, clean, ate. ✨

If the path you specify selects a mapping, yx prints the keys of that mapping, one per line. like so:

$ cat map.yaml
foo: one
bar: two
blah: argh
$ yx -f map.yaml
foo
bar
blah

If the path you specify selects a sequence, yx prints the list of valid indices, one per line. like so:

$ cat seq.yaml
[one, two, three]
$ yx -f seq.yaml
1
2
3

see? valid indices. one per line. gorgeous. πŸ‘‘

πŸ¦‹ HISTORY πŸ¦‹

yx was written as a helper utility for tiny-cloud, to parse user-data from shell scripts. so basically she started out as a little behind-the-scenes bestie and now she has her own manpage. glow up fr fr. 🌈

🫢 AUTHORS 🫢

Jake Buchholz GΓΆktΓΌrk <tomalok@gmail.com>


πŸ’– and that's the whole page, bestie! no cap, you're now a yx expert.

sign-off time: this one came from Debian, dated January 20, 2024. mwah, go forth and parse πŸ’œπŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from