cheshirekow / cmake_format

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

--config-file argument doesn't work #258

Closed sharadhr closed 1 year ago

sharadhr commented 3 years ago

How to reproduce:

  1. Execute cmake-format --dump-config > some/random/path/cmake-format.py
  2. Make some changes to the CMakeLists.txt file being worked on, that do not follow good formatting guidelines
  3. Execute cmake-format --config-file some/random/path/cmake-format.py; the above CMakeLists.txt is not changed whatsoever.

That said, leaving a cmake-format.json file in the same directory as the CMakeLists.txt and running cmake-format with no arguments works fine.

In my particular case, I was using $XDG_CONFIG_HOME/cmake-format.json which expands to /home/<my_username>/.config/cmake-format.json. I thought the full stop in the path might be causing problems, so I also tried /home//Desktop, which also doesn't work.

cheshirekow commented 3 years ago

--config-file takes multiple arguments. My guess is you wrote something like:

cmake-format --config-file /tmp/cmake-format.py /tmp/bad.cmake

But you should use

cmake-format --config-file /tmp/cmake-format.py -- /tmp/bad.cmake

(note the -- to terminate --config-file).

Yes, this is not ideal...

sharadhr commented 3 years ago

Thanks! Any chance of a fix?

I'm quite certain Python has a argument-parsing library, similar to C's getopt... Something like argparse?