Section 31 point 2: per-subcommand --database argument
This commit is contained in:
1 parent
37c1e845c0
commit
0629a30ae1
1 file changed
+13
-6
+13
-6
@@ -42,12 +42,13 @@ def delete_history_command(args):
|
|||||||
|
|
||||||
|
|
||||||
def build_parser():
|
def build_parser():
|
||||||
"""Return the argument parser for the maintenance commands."""
|
"""Return the argument parser for the maintenance commands.
|
||||||
parser = argparse.ArgumentParser(
|
|
||||||
prog="maintenance.py",
|
``--database`` is shared by every command, so it can be given after the
|
||||||
description="Maintenance tasks for VardKey that do not need the server.",
|
command name: ``maintenance.py delete-history --database /data/x.sqlite3``.
|
||||||
)
|
"""
|
||||||
parser.add_argument(
|
common = argparse.ArgumentParser(add_help=False)
|
||||||
|
common.add_argument(
|
||||||
"--database",
|
"--database",
|
||||||
default=None,
|
default=None,
|
||||||
help=(
|
help=(
|
||||||
@@ -55,9 +56,15 @@ def build_parser():
|
|||||||
f"{DEFAULT_DATABASE_PATH}."
|
f"{DEFAULT_DATABASE_PATH}."
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
prog="maintenance.py",
|
||||||
|
description="Maintenance tasks for VardKey that do not need the server.",
|
||||||
|
)
|
||||||
commands = parser.add_subparsers(dest="command", required=True)
|
commands = parser.add_subparsers(dest="command", required=True)
|
||||||
delete = commands.add_parser(
|
delete = commands.add_parser(
|
||||||
"delete-history",
|
"delete-history",
|
||||||
|
parents=[common],
|
||||||
help="Delete every saved health check and the follow-up it closed.",
|
help="Delete every saved health check and the follow-up it closed.",
|
||||||
)
|
)
|
||||||
delete.set_defaults(handler=delete_history_command)
|
delete.set_defaults(handler=delete_history_command)
|
||||||
|
|||||||
Reference in new issue
Block a user