SMQTK icon indicating copy to clipboard operation
SMQTK copied to clipboard

CLI utilities display invalid usage line

Open danlamanna opened this issue 8 years ago • 4 comments

Based on how the CLI utils are building the usage line, it's incorrectly marking required arguments as optional with the bracket notation.

For example, compute_many_descriptors -h shows:

usage: compute_many_descriptors [-h] [-v] [-c PATH] [-g PATH] [-b INT]
                                [--check-image] [-f PATH] [-p PATH]
...
optional arguments:
...

Required Arguments:
  -f PATH, --file-list PATH
                        Path to a file that lists data file paths. Paths in
                        this file may be relative, but will at some point be
                        coerced into absolute paths based on the current
                        working directory.
  -p PATH, --completed-files PATH
                        Path to a file into which we add CSV format lines
                        detailing filepaths that have been computed from the
                        file-list provided, as the UUID for that data
                        (currently the SHA1 checksum of the data).

Note the brackets around [-f PATH] [-p PATH] which indicates they are optional.

danlamanna avatar Jan 27 '17 18:01 danlamanna

I think at the time I first wrote that I didn't know how to tell argparse they were required under certain circumstances. Technically they are not required as the CLIs for most things allow for dumping configuration files, which doesn't require full options, e.g. compute_many_descriptors -g outconfig.json.

Purg avatar Jan 27 '17 18:01 Purg

Maybe the phrase "Required Arguments" could be rephrased to express when they are required and when they are not.

Purg avatar Jan 27 '17 18:01 Purg

I think this is traditionally handled with multiple usage lines, i.e.

usage: compute_many_descriptors [-v] -g PATH
       compute_many_descriptors [-v] -c PATH [-b INT] [--check-image] -f PATH -p PATH

danlamanna avatar Jan 27 '17 18:01 danlamanna

Makes sense. If you want to incrementally make that change to relevant tool argpase usage, go ahead.

Purg avatar Jan 27 '17 19:01 Purg