Format files¶
This guide shows the different ways to feed YAML content to yamkix and control where the formatted output goes.
Check the available options with yamkix --help (or see the CLI options reference).
Format a single yaml file and control where to output the outcome¶
- Use the
-i/--inputoption to identify the source file -
If you don't specify any output option with
-o/--outputor-s/--stdoutthen the result will overwrite the source file -
You can specify the target file with
-o/--output -
You can output the result to STDOUT using either
--output STDOUTor-s/--stdout -
If you use
-s/--stdoutand-i/--input, specifying an output file with-o/--outputwill not be taken into account
Read from STDIN¶
- You can format the input provide through
stdin -
stdininput can be specified explicitly, using--input STDIN -
stdininput is implicit if you don't specify any input through-i/--inputor any CLI argument: -
if
stdinis used for input and nothing is specified for output, thenstdoutwill be used for output.
Format multiple files¶
-
If you need to format multiple files in a single call to
Yamkix, don't use-i/--input, just pass the list of files as arguments to theyamkixcli
Note
It is not possible to output to stdout when formatting multiple files (feel free to raise an issue if you are interested in this feature).
Print a processing summary¶
- Use
--summaryto print processing statistics after all files have been processed - The summary includes:
- Total number of files processed
- Number of files that encountered parse errors
- Number of files with unchanged content (already properly formatted)
-
Total processing time
-
When combined with
--silent(which suppresses per-file config output), only the summary is printed to stderr:
List the modified files¶
- Use
--list-modifiedto print one stderr line per output file created or whose content changed, after processing - For in-place formatting, the reported path is the input file. With
--output, it is the destination, even if the source was already formatted.--stdoutand special files such as/dev/nullare not files whose content changed and produce no modified-file line - Changes are detected on raw bytes, so a file whose only change is its line endings (for example CRLF converted to LF) is listed, and not counted as unchanged by
--summary - Unchanged destinations and files that failed to parse are not listed; no modified-file lines appear when nothing changed. A destination that cannot be read is listed, since it cannot be compared
- If a later file fails to open, files modified earlier in the run are still listed before the command exits with an error. A file left partially written by a failure is listed too
-
Filenames containing control characters, or starting with a double quote, are printed between double quotes with backslash escapes (for example, a newline appears as
"a\nb.yml"), to keep one unambiguous report per line -
It can be combined with
--summary: the modified files are listed before the summary line