larryhastings / appeal

Command-line parsing library for Python 3.
Other
128 stars 7 forks source link

Suppress ValueError in "convert" phase, convert to usage exception #10

Closed larryhastings closed 1 year ago

larryhastings commented 1 year ago

Currently, if a user runs a program using Appeal:

import appeal
app = appeal.Appeal()
@app.global_command()
def main(a: int=0, b: str=''):
    print(f"main a={a} b='{b}'")
app.main()

and supplies a bad parameter to a converter:

% python bad.py 33.5 abc

they're rewarded with a traceback and a ValueError. Appeal should catch these and intelligently print a usage error. (That was the whole point of separating the "convert" phase from the "execute" phase, after all.)

larryhastings commented 1 year ago

Committed in a893b2e35d49be1836d5bdfb2c4fecc600c4bb27 (0.6). Well, the printing isn't super-intelligent yet, but we're getting there.