vss-tools icon indicating copy to clipboard operation
vss-tools copied to clipboard

Possible naming conflict -o and -ot

Open erikbosch opened this issue 1 year ago • 3 comments

As of today we support -o for overlays for --ot for type output when using structs. When working on enabling -ot only for cases when actually relevant I noticed that -ot then can get intepreted as -o t and you get a totally irrelevant error message.

I see some options for vss-tools 5.0:

  • Use a different "short name" for -otwith no conflicts, like -t
  • Remove the "short name", i.e. always request --types-output-file
  • Accept that error message becomes odd if using -ot on a tool that does not support it
erik@debian4:~/vss-tools/tests/vspec/test_structs$ ../../../vspec2ddsidl.py -vt VehicleDataTypes.vspec -u ../test_units.yaml -ot expt.json test.vspec exp.json
usage: vspec2ddsidl.py [-h] [-I dir] [-e EXTENDED_ATTRIBUTES] [-s] [--abort-on-unknown-attribute] [--abort-on-name-style] [--uuid] [-o overlays] [-q quantity_file] [-u unit_file]
                       [-vt vspec_types_file] [--all-idl-features]
                       <vspec_file> <output_file>
vspec2ddsidl.py: error: unrecognized arguments: exp.json
erik@debian4:~/vss-tools/tests/vspec/test_structs$ 

erikbosch avatar Apr 02 '24 07:04 erikbosch

I note that there is a -vt options that may have the same issue. It's nice to have the short options, but you can run out of letters...

Does the option parsing code we use allow for non-conflicting shortening of long options? That is, would --abort be allowed for --abort-on-unknown-attribute if there is no other option that starts with --abort? If so, not having short options for optional options that are not not used often would work well.

Using -t instead of -ot is one way around if short options are necessary, but may be harder or confusing to remember. Would -O be another option.

ppb2020 avatar Apr 02 '24 12:04 ppb2020

I think it is recommended to only use single characters for short options, so both -vt and -ot are "not recommended". Reason is that arg parser consider for example -x3 and -x 3 to be equal. -vt is currently not a problem as we have no -v

erikbosch avatar Apr 02 '24 14:04 erikbosch

MoM:

  • Erik presented the problem
  • PP: OK to go for only long name here
  • Erik: But if so backward incompatible change, so only for 5.0

erikbosch avatar Apr 02 '24 14:04 erikbosch