yamltidy(3)

πŸ“¦ version 0.10.0, in opensuse-leap 16.0

πŸ’– yamltidy(3) β€” Reformat YAML files, but make it cute πŸ’–

okay so this is a User Contributed Perl Documentation page for yamltidy(3), and it's literally about making your YAML files tidy. bestie, let's go. 🫢


✨ NAME ✨

yamltidy β€” Reformat YAML files.

🌸 ABSTRACT 🌸

Empty in the original β€” like, no abstract text here at all. Zero. Nada. πŸ™ˆ

πŸ’… DESCRIPTION πŸ’…

So this script checks YAML files according to a configuration and automatically reformats them. It'll output the formatted code on standard output, or edit the file directly. That's the whole assignment. πŸ’–

πŸŽ€ EXAMPLES πŸŽ€

Tidy a file and print to stdout

% cat in.yaml
---
a:
    b:
        c: d
% yamltidy in.yaml
---
a:
  b:
    c: d

Tidy content from stdin

% echo '---
a:
    b:
        c: d' | yamltidy -
---
a:
  b:
    c: d

Tidy a file and save the result back

% yamltidy --inplace in.yaml
% cat in.yaml
---
a:
  b:
    c: d

Process a list of files from stdin

# Tidy all .yaml files that are in git
% git ls-files | grep '.yaml$' | yamltidy --inplace --batch -
# short options
% git ls-files | grep '.yaml$' | yamltidy -i -b -
# Only tidy modified files
% git ls-files --modified | grep '.yaml$' | yamltidy --inplace --batch -

In the future yamltidy can take a directory as an argument and process file name patterns from configuration.

Use a certain configuration file

% yamltidy -c /path/to/yamltidy.yaml file.yaml

Partial formatting

From within an editor you can pass only a part of the file on stdin. This is important for keeping the indentation of that part. Also it won't add a --- header. Compare:

% echo '
  a:
      b: c' | yamltidy -
---
a:
  b: c
% echo '
    a:
        b: c' | yamltidy --partial -

    a:
      b: c

Vim example configuration

# :noremap <leader>yt :%!yamltidy -<CR>
# :vnoremap <leader>yt :!yamltidy --partial -<CR>

πŸ”₯ GLOBAL OPTIONS πŸ”₯

  • --config-file, -c β€” config file πŸ“
  • --config-data, -d β€” configuration as a string ✨
  • --inplace, -i β€” edit file inplace (flag) πŸ’…
  • --debug β€” debugging output (flag) πŸ”
  • --partial β€” input is only a part of a YAML file (flag) 🧩
  • --indent β€” override indentation spaces from config πŸ“
  • --batch, -b β€” tidy all files; currently requires parameter "-" for filenames passed via STDIN (flag) πŸ—‚οΈ
  • --verbose β€” output information (flag) πŸ“£
  • --help, -h β€” print usage message and exit (flag) πŸ†˜
  • --version β€” print version information (flag) 🏷️

πŸ¦‹ SUBCOMMANDS πŸ¦‹

Okay so this section is empty in the original β€” no subcommands listed. πŸ’€


πŸ’Œ cute sign-off: this page is from perl v5.42.0, dated 2024-02-02, and it's the yamltidy(3) manual. bye bestie, go tidy some YAML! βœ¨πŸ’…

πŸ“¦ where this page comes from