I am trying click (Command line interface package for Python), while running the following code I get error
Error: No such command "abcd"
def cli(ctx, source):
ctx.obj = "pass it"
def hello(ctx, abcd):
if __name__ == '__main__':
python playclick.py --source this abcd
"abcd" is being treated as a separate command because of the space (this is a characteristic of your shell, not of click specifically).
If you want the value of
source to be "this abcd", use quotes:
python playclick.py --source "this abcd"
To actually provide the
abcd argument, you need to call the
hello command – the argument is for that command:
python playclick.py --source this hello 123456
hello command will have an argument of
Breaking down the entire line:
--source this provides the
source argument to the main
hello is the command to run (try
python playclick.py --source this and you'll get an error because there is no command), and
123456 is the argument named
abcd to that command.