Skip to content

Support for shorthand #8

@Henri-ColibrITD

Description

@Henri-ColibrITD

It would be supper nice to be able to have short-hands, here is an example of what it looks like with argparse, followed by an idea of what it could look like with argtyped.

parser = argparse.ArgumentParser(
    prog="DB initialization helper",
    description="This script initializes the database.",
)

parser.add_argument(
    "-n",
    "--table-name",
    help="The name of the table to initialize",
    default="test",
)

Could be equivalent to

class Parser(Arguments):
    """This script initializes the database."""

    table_name: Shorthanded[str] = "test"
    """The name of the table to initialize"""

I'm just throwing ideas around, without considering the feasibility. An other solution would be to put the keyword on the right hand side of the equality instead of the type hint. Similarly to the Field class of pydantic I believe. Like so:

class Parser(Arguments):
    """This script initializes the database."""

    table_name: str = Shorthanded("test")
    """The name of the table to initialize"""

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions