Package: fastarg
FastargFastarg is a command line argument parser utility that is built on Python's standard argparse library.Installationpip3 install fastargGetting startedmain.pyimport fastarg

app = fastarg.Fastarg(description="hello world")

@app.command()
def hello_world(name: str):
    """hello world"""
    print("hello " + name)

if __name__ == "__main__":
    app.run()Run command:$ python3 main.py hello_world fooShow help text:$ python3 main.py -hSubcommandsCreate arbitrarily large trees of subcommands.import fastarg

app = fastarg.Fastarg(description="productivity app", prog="todo")
app2 = fastarg.Fastarg(description="to do", help="manage todos")
app3 = fastarg.Fastarg(description="user", help="manage users")
app4 = fastarg.Fastarg(description="address", help="manage addresses")

@app.command()
def hello_world(name: str):
    """hello world"""
    print("hello " + name)

@app2.command()
def create_todo(title: str, completed: bool = False):
    """create a todo"""
    print(f"create todo: {title} - {completed}")

@app2.command()
def update_todo(
    id: int = fastarg.Argument(help="the primary key of todo"), 
    completed: bool = fastarg.Option(False, help="completed status")
    ):
    """update a todo"""
    print(f"update todo: {id} - {completed}")

@app3.command()
def create_user(email: str, password: str, gold: float):
    """create a user"""
    print(f"creating {email}/{password} with {gold} gold")

@app3.command()
def delete_user(email: str):
    """delete a user"""
    print(f"deleting user {email}")

@app4.command()
def create_address(
    user_id: int, 
    address: str, 
    city: str = fastarg.Option("", help="city (e.g. Seattle)"), 
    state: str = fastarg.Option("", help="state (e.g. WA)"), 
    zip: str = fastarg.Option("", help="zip")
    ):
    """create address for user"""
    print(f"creating address for user {user_id}")
    print(f"{address} {city} {state} {zip}")


app.add_fastarg(app2, name="todo")
app.add_fastarg(app3, name="user")
app3.add_fastarg(app4, name="address")

if __name__ == "__main__":
    app.run()Example usageRun hello world:$ python3 main.py hello_world fooShow help text for todo subcommand:$ python3 main.py todo -hShow help text for a subcommand:$ python3 main.py todo update_todo -hRun create_todo subcommand:$ python3 main.py todo create_todo "drink water"Run create_todo with optional completed flag:$ python3 main.py todo create_todo "drink water" --completed
$ python3 main.py todo create_todo "drink water" --no-completedRun the nested create_address command:$ python3 main.py user address create_address 123 "456 main st" --city bellevue --state wa --zip 98004ArgumentsPositional arguments are required. For example, the create_todo command takes a positional argument of title.OptionsOptions are optional. For example, the create_address command takes an optional argument of city, state, and zip.Subcommands in multiple filesmain.pyimport fastarg
import commands.todo as todo
import commands.user as user

app = fastarg.Fastarg(description="productivity app", prog="todo")

@app.command()
def hello_world(name: str):
    """hello world"""
    print("hello " + name)

app.add_fastarg(todo.app, name="todo")
app.add_fastarg(user.app, name="user")

if __name__ == "__main__":
    app.run()commands/todo.pyimport fastarg

app = fastarg.Fastarg(description="to do", help="manage todos")

@app.command()
def create_todo(title: str, completed: bool = False):
    """create a todo"""
    print(f"create todo: {title} - {completed}")

@app.command()
def update_todo(
    id: int = fastarg.Argument(help="the primary key of todo"), 
    completed: bool = fastarg.Option(False, help="completed status")
    ):
    """update a todo"""
    print(f"update todo: {id} - {completed}")commands/user.pyimport fastarg
import commands.address as address

app = fastarg.Fastarg(description="user", help="manage users")

@app.command()
def create_user(email: str, password: str, gold: float):
    """create a user"""
    print(f"creating {email}/{password} with {gold} gold")

@app.command()
def delete_user(email: str):
    """delete a user"""
    print(f"deleting user {email}")

app.add_fastarg(address.app, name="address")Exampleshttps://github.com/travisluong/fastarg/tree/main/examplesAuthorTravis Luong