Limit argument range for --verbose, make default log level more explicit. (#93)
This commit is contained in:
parent
e7b128e735
commit
a836ec944f
3 changed files with 7 additions and 3 deletions
|
@ -92,6 +92,8 @@ def parse_arguments(*arguments):
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-v', '--verbosity',
|
'-v', '--verbosity',
|
||||||
type=int,
|
type=int,
|
||||||
|
choices=range(0,3),
|
||||||
|
default=0,
|
||||||
help='Display verbose progress (1 for some, 2 for lots)',
|
help='Display verbose progress (1 for some, 2 for lots)',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ def test_parse_arguments_with_no_arguments_uses_defaults():
|
||||||
|
|
||||||
assert parser.config_paths == config_paths
|
assert parser.config_paths == config_paths
|
||||||
assert parser.excludes_filename == None
|
assert parser.excludes_filename == None
|
||||||
assert parser.verbosity is None
|
assert parser.verbosity is 0
|
||||||
assert parser.json is False
|
assert parser.json is False
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ def test_parse_arguments_with_path_arguments_overrides_defaults():
|
||||||
|
|
||||||
assert parser.config_paths == ['myconfig']
|
assert parser.config_paths == ['myconfig']
|
||||||
assert parser.excludes_filename == 'myexcludes'
|
assert parser.excludes_filename == 'myexcludes'
|
||||||
assert parser.verbosity is None
|
assert parser.verbosity is 0
|
||||||
|
|
||||||
|
|
||||||
def test_parse_arguments_with_multiple_config_paths_parses_as_list():
|
def test_parse_arguments_with_multiple_config_paths_parses_as_list():
|
||||||
|
@ -34,7 +34,7 @@ def test_parse_arguments_with_multiple_config_paths_parses_as_list():
|
||||||
parser = module.parse_arguments('--config', 'myconfig', 'otherconfig')
|
parser = module.parse_arguments('--config', 'myconfig', 'otherconfig')
|
||||||
|
|
||||||
assert parser.config_paths == ['myconfig', 'otherconfig']
|
assert parser.config_paths == ['myconfig', 'otherconfig']
|
||||||
assert parser.verbosity is None
|
assert parser.verbosity is 0
|
||||||
|
|
||||||
|
|
||||||
def test_parse_arguments_with_verbosity_flag_overrides_default():
|
def test_parse_arguments_with_verbosity_flag_overrides_default():
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
VERBOSITY_WARNING = 0
|
||||||
VERBOSITY_SOME = 1
|
VERBOSITY_SOME = 1
|
||||||
VERBOSITY_LOTS = 2
|
VERBOSITY_LOTS = 2
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ def verbosity_to_log_level(verbosity):
|
||||||
Given a borgmatic verbosity value, return the corresponding Python log level.
|
Given a borgmatic verbosity value, return the corresponding Python log level.
|
||||||
'''
|
'''
|
||||||
return {
|
return {
|
||||||
|
VERBOSITY_WARNING: logging.WARNING,
|
||||||
VERBOSITY_SOME: logging.INFO,
|
VERBOSITY_SOME: logging.INFO,
|
||||||
VERBOSITY_LOTS: logging.DEBUG,
|
VERBOSITY_LOTS: logging.DEBUG,
|
||||||
}.get(verbosity, logging.WARNING)
|
}.get(verbosity, logging.WARNING)
|
||||||
|
|
Loading…
Reference in a new issue