microsoft / knack

Knack - A Python command line interface framework
https://pypi.python.org/pypi/knack
MIT License
347 stars 95 forks source link

Add error message for invalid argument value #244

Closed jiasli closed 3 years ago

jiasli commented 3 years ago

Fix #236 Migrated from https://github.com/microsoft/knack/pull/237

Symptom

Knack can only give error message for invalid command, but not invalid argument value. History: https://github.com/microsoft/knack/pull/237#issuecomment-801876101

Change

Add error message for invalid argument value.

Testing guide

> python examples\exapp2 demo arg1
exapp2 demo: 'arg1' is not in the 'exapp2 demo' command group. See 'exapp2 demo --help'.

The most similar choices to 'arg1':
        arg

> python D:\cli\knack\examples\exapp2 demo arg --move rok
exapp2 demo arg: 'rok' is not a valid value for '--move'.
Allowed values: rock, paper, scissors

ℹ As Allowed values: rock, paper, scissors appears in one line, it is not needed to add an empty line before it.