Given the code
import argh
@argh.arg("paths", nargs="*", default=["x", "z"])
def fun(paths:list[str]):
print(paths)
if __name__ == "__main__":
argh.dispatch_command(fun)
> ./app.py
["x", "z"] # as expected - the value of 'default'
> ./app.py a b
[["a"], ["b"]] # Bug? I would expect ["a", "b"]
If I use argparse, it works fine
parser = argparse.ArgumentParser()
parser.add_argument("paths", nargs="*", default=["x", "y"])
print(parser.parse_args([]))
print(parser.parse_args(["a", "b"]))
> Namespace(paths=['x', 'y'])
> Namespace(paths=['a', 'b'])
If I don't specify the 'default' arg things work fine:
@argh.arg("paths", nargs="*")
def with_argh(paths:list[str]):
print(paths)
> ./app.py a b
["a", "b"]
Using latest 0.30.4