canonical / craft-cli

https://canonical-craft-cli.readthedocs-hosted.com/en/latest/
GNU Lesser General Public License v3.0
9 stars 15 forks source link

Disable long option abbreviation (`--destructive` vs `--destructive-mode`) #261

Open mattculler opened 2 months ago

mattculler commented 2 months ago

What needs to get done

By default, argparse allows abbreviated commands, such as --destructive-mode being specified as --destructive.

Since Python 3.5, this default behavior can be disabled by setting allow_abbrev=False when instantiating argparse.ArgumentParser:

https://docs.python.org/3/library/argparse.html#allow-abbrev

Found by @thp-canonical and @Ardelean-Calin

Why it needs to get done

This avoids wrongly learning command-line arguments that might at some point not be unique anymore.

syncronize-issues-to-jira[bot] commented 2 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3114.

This message was autogenerated