fredrik-corneliusson / click-web

Serve click scripts over the web
MIT License
265 stars 17 forks source link

[cmd_exec] fix for one dash option #10

Closed mareksimunek closed 3 years ago

mareksimunek commented 3 years ago

When having option with one dash, command is not processed properly: (but one dash is valid option https://click.palletsprojects.com/en/8.0.x/options/#basic-value-options) e.g

@cli.command()
@click.option("-d", "--delay", type=float, default=0.01, help='delay for every line print')
@click.argument("lines", default=10, type=int)
[2021-07-22 15:54:42,258] INFO in cmd_exec: arg_value: "['-0.99']"
[2021-07-22 15:54:42,258] INFO in cmd_exec: arg_value: "['10']"
127.0.0.1 - - [22/Jul/2021 15:54:42] "POST /cli/print-rows HTTP/1.1" 200 -
[2021-07-22 15:54:42,259] INFO in cmd_exec: Executing: ['/venv/bin/python3', '/a.py', 'print-rows', '-0.99', '10']

Option -d is and considered as arg_value Thus output:

Usage: a.py print-rows [OPTIONS] [LINES]
Try 'a.py print-rows --help' for help.

Error: no such option: -0
mareksimunek commented 3 years ago

@fredrik-corneliusson

fredrik-corneliusson commented 3 years ago

@mareksimunek Thanks for the fix! Sorry for the late reply have been on vacation.