stratis-storage/stratis-cli

Rename command line options that contain dashes

Closed this issue · 3 comments

CLI options that contain dashes, are parsed using only the content before the dash.
For example, --keyfile-path is equivalent to --keyfile, and --capture-key is equivalent to --capture.

An example of this behavior is seen here: https://github.com/stratis-storage/stratis-cli/blob/develop-2.0.1/tests/whitebox/integration/key/test_reset.py#L44

It may be worth discarding the dash or renaming these options for the sake of clarity.

I'll want to check into this a bit...

It turns out that there is some internal logic in the parser that allows it to match any disambiguating prefix. Here's an example of a parser interaction:

>>> parser.parse_args(["key", "set", "name", "--k", "name"])
Namespace(capture_key=False, func=<function add_subcommand.<locals>.wrap_func.<locals>.wrapped_func at 0x7ff9ebdd4200>, keydesc='name', keyfile_path=['name'], propagate=False)

showing that -k is enough.

We can turn that off with a flag, though: https://docs.python.org/3.8/library/argparse.html#allow-abbrev. We might not want to, though, as users will find shorter strings convenient. We can discuss in standup.

The reason to require a complete match of the option name is to avoid users getting used to the prefix, and then to have the same prefix correspond to a different option name, because the old option name was removed and a new one w/ the same prefix was added. But we're not proliferating options all that rapidly, and the users wish to type as few characters as possible is often pretty strong. So we'll stick with the parser set up as it is.