-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Love the project ! But IMO it's missing some key features for me to use it. The main one being documentation. Here is an example to what I'd love to have:
parser = argparse.ArgumentParser(
prog="DB initialization helper",
description="This script initializes the database and optionally add constraints.",
)
parser.add_argument(
"-n",
"--table-name",
help="The name of the table to initialize",
default="test",
)
parser.add_argument(
"--constraints",
action=argparse.BooleanOptionalAction,
default=True,
help="Wether the constraints should be added or not",
)
arguments = parser.parse_args(sys.argv[1:])
print(arguments)could be equivalent to
class Parser(Arguments):
"""This script initializes the database and optionally add constraints
and data."""
table_name: str = "test"
"""The name of the table to initialize"""
constraints: Switch = True
"""Wether the constraints should be added or not"""
arguments = Parser(sys.argv[1:])for now, the first one gives this help:
usage: DB initialization helper [-h] [-n TABLE_NAME] [--constraints | --no-constraints]
This script initializes the database and optionally add constraints and data.
optional arguments:
-h, --help show this help message and exit
-n TABLE_NAME, --table-name TABLE_NAME
The name of the table to initialize
--constraints, --no-constraints
Wether the constraints should be added or not (default: True)
while the later gives
usage: init_db.py [-h] [--table-name TABLE_NAME] [--constraints] [--no-constraints]
optional arguments:
-h, --help show this help message and exit
--table-name TABLE_NAME
--constraints
--no-constraints
Here the improvements would be:
- support for docstring as help
Switchcould useargparse.BooleanOptionalActionso that the documentation looks nicer
There is also the support for shorthands which would be nice, but I'll create a separate issue for this.
Metadata
Metadata
Assignees
Labels
No labels