cmake_format icon indicating copy to clipboard operation
cmake_format copied to clipboard

[cmake-lint] Problem with -c command line arg

Open garethsb opened this issue 4 years ago • 1 comments

cmake-lint -c .cmake-format.py CMakeLists.txt doesn't work. cmake-lint CMakeLists.txt -c .cmake-format.py does.

From the usage description I don't think that's intended, but it does hint at the explanation.

usage:
cmake-lint [-h]
           [--dump-config {yaml,json,python} | -o OUTFILE_PATH]
           [-c CONFIG_FILE]
           infilepath [infilepath ...]

Check cmake listfile for lint

positional arguments:
  infilepaths

optional arguments:
...
  -c CONFIG_FILES [CONFIG_FILES ...], --config-files CONFIG_FILES [CONFIG_FILES ...]
                        path to configuration file(s)

In the top usage description -c is described as taking a single CONFIG_FILE, and the infilepaths follow. In the detailed explanation, -c is described as taking multiple CONFIG_FILES.

Presumably -c is swallowing the infilepath args if it's supplied in the more obvious place before them.

garethsb avatar Aug 05 '21 10:08 garethsb

Although this issue has been opened a long time ago, I'm just noting a possible additional solution.

This can be also resolved using double dash characters -- to signify the end of command options and beginning of arguments, like this:

cmake-lint --config-files path/to/cmake-format.json -- CMakeLists.txt

petk avatar Sep 01 '23 00:09 petk