Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow positional parameters for a collection to be passed without a name #61

Open
richieadler opened this issue Aug 15, 2024 · 0 comments

Comments

@richieadler
Copy link

Given

# adder1.py
from clipstick import parse
from pydantic import BaseModel

class Adder(BaseModel):
    ints: int

    def run(self):
        print(sum([self.ints]))

cmd = parse(Adder)
cmd.run()

this runs OK:

$ adder1.py 10
10

but this

# adder2.py
from clipstick import parse
from pydantic import BaseModel

class Adder(BaseModel):
    ints: list[int]

    def run(self):
        print(sum(self.ints))

cmd = parse(Adder)
cmd.run()

fails for multiple arguments:

$ adder2.py 10 20

ERROR:
Missing a value for positional argument '--ints'

and requires

$ adder2.py --ints 10 --ints 20
30

It would be desirable that positional arguments for a collection could be passed just as values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant