Allow --verbose or -vvv for any subcommand as well as at the top level.

This commit is contained in:
Chris Berkhout 2021-07-16 11:52:57 +02:00
parent 73c5f3a1c6
commit b00bca3903

View file

@ -130,6 +130,7 @@ def build_parser():
) )
parser.add_argument( parser.add_argument(
"-vvv",
"--verbose", "--verbose",
action="store_true", action="store_true",
help="show all log messages", help="show all log messages",
@ -137,11 +138,17 @@ def build_parser():
subparsers = parser.add_subparsers(title="commands", dest="command") subparsers = parser.add_subparsers(title="commands", dest="command")
subparsers.add_parser( sources_parser = subparsers.add_parser(
"sources", "sources",
help="list sources", help="list sources",
formatter_class=formatter, formatter_class=formatter,
) )
sources_parser.add_argument(
"-vvv",
"--verbose",
action="store_true",
help="show all log messages",
)
source_parser = subparsers.add_parser( source_parser = subparsers.add_parser(
"source", "source",
@ -156,6 +163,12 @@ def build_parser():
choices=sources.by_id.keys(), choices=sources.by_id.keys(),
help="the source identifier", help="the source identifier",
) )
source_parser.add_argument(
"-vvv",
"--verbose",
action="store_true",
help="show all log messages",
)
source_list_or_search = source_parser.add_mutually_exclusive_group(required=False) source_list_or_search = source_parser.add_mutually_exclusive_group(required=False)
source_list_or_search.add_argument( source_list_or_search.add_argument(
@ -177,7 +190,7 @@ def build_parser():
usage=( usage=(
# Set usage manually to have positional arguments before options # Set usage manually to have positional arguments before options
# and show allowed values where appropriate # and show allowed values where appropriate
"pricehist fetch SOURCE PAIR [-h] " "pricehist fetch SOURCE PAIR [-h] [-vvv] "
"[-t TYPE] [-s DATE | -sx DATE] [-e DATE | -ex DATE] " "[-t TYPE] [-s DATE | -sx DATE] [-e DATE | -ex DATE] "
f"[-o {'|'.join(outputs.by_type.keys())}] " f"[-o {'|'.join(outputs.by_type.keys())}] "
"[--invert] [--quantize INT] " "[--invert] [--quantize INT] "
@ -201,6 +214,12 @@ def build_parser():
type=valid_pair, type=valid_pair,
help="pair, usually BASE/QUOTE, e.g. BTC/USD", help="pair, usually BASE/QUOTE, e.g. BTC/USD",
) )
fetch_parser.add_argument(
"-vvv",
"--verbose",
action="store_true",
help="show all log messages",
)
fetch_parser.add_argument( fetch_parser.add_argument(
"-t", "-t",
"--type", "--type",