cmake-format - Parse cmake listfiles and format them nicely.
cmake-format [-h] [--dump-config {yaml,json,python} | -i |
-o OUTFILE_PATH] [-c CONFIG_FILE] infilepath [infilepath ...]
Parse cmake listfiles and format them nicely.
Formatting is configurable by providing a configuration file. The
configuration file can be in json, yaml, or python format. If no
configuration file is specified on the command line, cmake-format will
attempt to find a suitable configuration for each ``inputpath`` by checking
recursively checking it's parent directory up to the root of the filesystem.
It will return the first file it finds with a filename that matches
'\.?cmake-format(.yaml|.json|.py)'.
cmake-format can spit out the default configuration for you as
starting point for customization. Run with `--dump-config
[yaml|json|python]`.
- infilepaths
-
- -v, --version
- show program's version number and exit
- -l
{error,warning,info,debug}, --log-level
{error,warning,info,debug}
-
- --dump-config
[{yaml,json,python}]
- If specified, print the default configuration to stdout and exit
- --dump
{lex,parse,parsedb,layout,markup}
-
- --no-help
- When used with --dump-config, will omit helptext comments in the output
- --no-default
- When used with --dump-config, will omit any unmodified configuration
value.
- -i,
--in-place
-
- --check
- Exit with status code 0 if formatting would not change file contents, or
status code 1 if it would
- -o OUTFILE_PATH,
--outfile-path OUTFILE_PATH
- Where to write the formatted file. Default is stdout.
- -c CONFIG_FILES
[CONFIG_FILES ...], --config-files CONFIG_FILES [CONFIG_FILES
...]
- path to configuration file(s)
- --disable
[DISABLE]
- Disable formatting entirely, making cmake-format a no-op
- --line-width
LINE_WIDTH
- How wide to allow formatted cmake files
- --tab-size
TAB_SIZE
- How many spaces to tab for indent
- --use-tabchars
[USE_TABCHARS]
- If true, lines are indented using tab characters (utf-8 0x09) instead of
<tab_size> space characters (utf-8 0x20). In cases where the layout
would require a fractional tab character, the behavior of the fractional
indentation is governed by <fractional_tab_policy>
- --fractional-tab-policy
{use-space,round-up}
- If <use_tabchars> is True, then the value of this variable indicates
how fractional indentions are handled during whitespace replacement. If
set to 'use-space', fractional indentation is left as spaces (utf-8 0x20).
If set to `round-up` fractional indentation is replaced with a single tab
character (utf-8 0x09) effectively shifting the column to the next tabstop
- --max-subgroups-hwrap
MAX_SUBGROUPS_HWRAP
- If an argument group contains more than this many sub-groups (parg or
kwarg groups) then force it to a vertical layout.
- --max-pargs-hwrap
MAX_PARGS_HWRAP
- If a positional argument group contains more than this many arguments,
then force it to a vertical layout.
- --max-rows-cmdline
MAX_ROWS_CMDLINE
- If a cmdline positional group consumes more than this many lines without
nesting, then invalidate the layout (and nest)
- --separate-ctrl-name-with-space
[SEPARATE_CTRL_NAME_WITH_SPACE]
- If true, separate flow control names from their parentheses with a space
- --separate-fn-name-with-space
[SEPARATE_FN_NAME_WITH_SPACE]
- If true, separate function names from parentheses with a space
- --dangle-parens
[DANGLE_PARENS]
- If a statement is wrapped to more than one line, than dangle the closing
parenthesis on its own line.
- --dangle-align
{prefix,prefix-indent,child,off}
- If the trailing parenthesis must be 'dangled' on its on line, then align
it to this reference: `prefix`: the start of the statement,
`prefix-indent`: the start of the statement, plus one indentation level,
`child`: align to the column of the arguments
- --min-prefix-chars
MIN_PREFIX_CHARS
- If the statement spelling length (including space and parenthesis) is
smaller than this amount, then force reject nested layouts.
- --max-prefix-chars
MAX_PREFIX_CHARS
- If the statement spelling length (including space and parenthesis) is
larger than the tab width by more than this amount, then force reject
un-nested layouts.
- --max-lines-hwrap
MAX_LINES_HWRAP
- If a candidate layout is wrapped horizontally but it exceeds this many
lines, then reject the layout.
- --line-ending
{windows,unix,auto}
- What style line endings to use in the output.
- --command-case
{lower,upper,canonical,unchanged}
- Format command names consistently as 'lower' or 'upper' case
- --keyword-case
{lower,upper,unchanged}
- Format keywords consistently as 'lower' or 'upper' case
- --always-wrap
[ALWAYS_WRAP ...]
- A list of command names which should always be wrapped
- --enable-sort
[ENABLE_SORT]
- If true, the argument lists which are known to be sortable will be sorted
lexicographicall
- --autosort
[AUTOSORT]
- If true, the parsers may infer whether or not an argument list is sortable
(without annotation).
- --require-valid-layout
[REQUIRE_VALID_LAYOUT]
- By default, if cmake-format cannot successfully fit everything into the
desired linewidth it will apply the last, most aggressive attempt that it
made. If this flag is True, however, cmake-format will print error, exit
with non-zero status code, and write-out nothing
Josh Bialkowski
josh.bialkowski@gmail.com