cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
962 stars 105 forks source link

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

Open garethsb opened 3 years ago

garethsb commented 3 years ago

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.

petk commented 1 year ago

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