Browse Source

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

tags/1.2.3
floli 10 months ago
parent
commit
a836ec944f

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

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

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

@@ -14,7 +14,7 @@ def test_parse_arguments_with_no_arguments_uses_defaults():
14 14
 
15 15
     assert parser.config_paths == config_paths
16 16
     assert parser.excludes_filename == None
17
-    assert parser.verbosity is None
17
+    assert parser.verbosity is 0
18 18
     assert parser.json is False
19 19
 
20 20
 
@@ -25,7 +25,7 @@ def test_parse_arguments_with_path_arguments_overrides_defaults():
25 25
 
26 26
     assert parser.config_paths == ['myconfig']
27 27
     assert parser.excludes_filename == 'myexcludes'
28
-    assert parser.verbosity is None
28
+    assert parser.verbosity is 0
29 29
 
30 30
 
31 31
 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():
34 34
     parser = module.parse_arguments('--config', 'myconfig', 'otherconfig')
35 35
 
36 36
     assert parser.config_paths == ['myconfig', 'otherconfig']
37
-    assert parser.verbosity is None
37
+    assert parser.verbosity is 0
38 38
 
39 39
 
40 40
 def test_parse_arguments_with_verbosity_flag_overrides_default():

+ 2
- 0
borgmatic/verbosity.py View File

@@ -1,6 +1,7 @@
1 1
 import logging
2 2
 
3 3
 
4
+VERBOSITY_WARNING = 0
4 5
 VERBOSITY_SOME = 1
5 6
 VERBOSITY_LOTS = 2
6 7
 
@@ -10,6 +11,7 @@ def verbosity_to_log_level(verbosity):
10 11
     Given a borgmatic verbosity value, return the corresponding Python log level.
11 12
     '''
12 13
     return {
14
+        VERBOSITY_WARNING: logging.WARNING,
13 15
         VERBOSITY_SOME: logging.INFO,
14 16
         VERBOSITY_LOTS: logging.DEBUG,
15 17
     }.get(verbosity, logging.WARNING)

Loading…
Cancel
Save