Browse Source

Limit argument range for --verbose, make default log level more explicit. (#93)

tags/1.2.3
floli 1 year ago
parent
commit
a836ec944f
3 changed files with 7 additions and 3 deletions
  1. +2
    -0
      borgmatic/commands/borgmatic.py
  2. +3
    -3
      borgmatic/tests/integration/commands/test_borgmatic.py
  3. +2
    -0
      borgmatic/verbosity.py

+ 2
- 0
borgmatic/commands/borgmatic.py View File

@@ -92,6 +92,8 @@ def parse_arguments(*arguments):
parser.add_argument(
'-v', '--verbosity',
type=int,
choices=range(0,3),
default=0,
help='Display verbose progress (1 for some, 2 for lots)',
)


+ 3
- 3
borgmatic/tests/integration/commands/test_borgmatic.py View File

@@ -14,7 +14,7 @@ def test_parse_arguments_with_no_arguments_uses_defaults():

assert parser.config_paths == config_paths
assert parser.excludes_filename == None
assert parser.verbosity is None
assert parser.verbosity is 0
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.excludes_filename == 'myexcludes'
assert parser.verbosity is None
assert parser.verbosity is 0


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')

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():

+ 2
- 0
borgmatic/verbosity.py View File

@@ -1,6 +1,7 @@
import logging


VERBOSITY_WARNING = 0
VERBOSITY_SOME = 1
VERBOSITY_LOTS = 2

@@ -10,6 +11,7 @@ def verbosity_to_log_level(verbosity):
Given a borgmatic verbosity value, return the corresponding Python log level.
'''
return {
VERBOSITY_WARNING: logging.WARNING,
VERBOSITY_SOME: logging.INFO,
VERBOSITY_LOTS: logging.DEBUG,
}.get(verbosity, logging.WARNING)

Loading…
Cancel
Save