Allow use of --stats flag when --create or --prune flags are implied (#139).
This commit is contained in:
parent
031b9d6faf
commit
2dc006aab4
3 changed files with 19 additions and 8 deletions
1
NEWS
1
NEWS
|
@ -1,5 +1,6 @@
|
|||
1.2.15.dev0
|
||||
* #136: Handle and format validation errors raised during argument parsing.
|
||||
* #139: Allow use of --stats flag when --create or --prune flags are implied.
|
||||
|
||||
1.2.14
|
||||
* #103: When generating sample configuration with generate-borgmatic-config, document the defaults
|
||||
|
|
|
@ -166,9 +166,6 @@ def parse_arguments(*arguments):
|
|||
if args.progress and not args.create:
|
||||
raise ValueError('The --progress option can only be used with the --create option')
|
||||
|
||||
if args.stats and not (args.create or args.prune):
|
||||
raise ValueError('The --stats option can only be used with the --create or --prune options')
|
||||
|
||||
if args.json and not (args.create or args.list or args.info):
|
||||
raise ValueError(
|
||||
'The --json option can only be used with the --create, --list, or --info options'
|
||||
|
@ -181,12 +178,21 @@ def parse_arguments(*arguments):
|
|||
|
||||
# If any of the action flags are explicitly requested, leave them as-is. Otherwise, assume
|
||||
# defaults: Mutate the given arguments to enable the default actions.
|
||||
if args.init or args.prune or args.create or args.check or args.list or args.info:
|
||||
return args
|
||||
if (
|
||||
not args.init
|
||||
and not args.prune
|
||||
and not args.create
|
||||
and not args.check
|
||||
and not args.list
|
||||
and not args.info
|
||||
):
|
||||
args.prune = True
|
||||
args.create = True
|
||||
args.check = True
|
||||
|
||||
if args.stats and not (args.create or args.prune):
|
||||
raise ValueError('The --stats option can only be used when creating or pruning archives')
|
||||
|
||||
args.prune = True
|
||||
args.create = True
|
||||
args.check = True
|
||||
return args
|
||||
|
||||
|
||||
|
|
|
@ -158,6 +158,10 @@ def test_parse_arguments_with_stats_flag_but_no_create_or_prune_flag_raises_valu
|
|||
module.parse_arguments('--stats', '--list')
|
||||
|
||||
|
||||
def test_parse_arguments_with_just_stats_flag_does_not_raise():
|
||||
module.parse_arguments('--stats')
|
||||
|
||||
|
||||
def test_parse_arguments_allows_json_with_list_or_info():
|
||||
module.parse_arguments('--list', '--json')
|
||||
module.parse_arguments('--info', '--json')
|
||||
|
|
Loading…
Reference in a new issue