Skip to content

Possible to have dataclass-like parameters? #137

Answered by DanCardin
blakeNaccarato asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not entirely sure whether i'm fully grasping the complexities in this example or not. But if it's just a matter of making singular CLI inputs parse into arbitrary shapes, then you ought to be able to use Arg.parse to specify the custom mechanism required to turn that string input into the object you want.

I've simplified your example into what seems like the minimal request here.

from __future__ import annotations

from collections.abc import Callable
from json import loads
from typing import Annotated, TypeVar

from cappa.arg import Arg
from cappa.base import command, invoke
from pydantic import BaseModel

T = TypeVar("T", bound=BaseModel)


def main(stage: MakeIceCream):
    print(
…

Replies: 5 comments 15 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@DanCardin
Comment options

Answer selected by blakeNaccarato
@blakeNaccarato
Comment options

@DanCardin
Comment options

Comment options

You must be logged in to vote
10 replies
@DanCardin
Comment options

@blakeNaccarato
Comment options

@DanCardin
Comment options

@pawamoy
Comment options

@blakeNaccarato
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@DanCardin
Comment options

@blakeNaccarato
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants