canonical / canonical/craft-cli

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

Open
#261 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
16
Forks
27
Avg merge
2d 1h
Merged PRs (30d)
12

Description

### 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.