Make install command beta.
This commit is contained in:
parent
acf94abe26
commit
750f90db4c
2 changed files with 20 additions and 6 deletions
|
@ -59,16 +59,24 @@ class UnresolvableRequirementsError(cdist.Error):
|
|||
class CdistBetaRequired(cdist.Error):
|
||||
"""Beta functionality is used but beta is not enabled"""
|
||||
|
||||
def __init__(self, command, arg):
|
||||
def __init__(self, command, arg=None):
|
||||
self.command = command
|
||||
self.arg = arg
|
||||
|
||||
def __str__(self):
|
||||
err_msg = ("\'{}\' argument of \'{}\' command is beta, but beta is "
|
||||
if self.arg is None:
|
||||
err_msg = ("\'{}\' command is beta, but beta is "
|
||||
"not enabled. If you want to use it please enable beta "
|
||||
"functionalities by using the -b/--enable-beta command "
|
||||
"line flag.")
|
||||
return err_msg.format(self.arg, self.command)
|
||||
fmt_args = [self.command, ]
|
||||
else:
|
||||
err_msg = ("\'{}\' argument of \'{}\' command is beta, but beta "
|
||||
"is not enabled. If you want to use it please enable "
|
||||
"beta functionalities by using the -b/--enable-beta "
|
||||
"command line flag.")
|
||||
fmt_args = [self.arg, self.command, ]
|
||||
return err_msg.format(*fmt_args)
|
||||
|
||||
|
||||
class CdistObjectError(Error):
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#
|
||||
|
||||
|
||||
# list of beta sub-commands
|
||||
BETA_COMMANDS = ['install', ]
|
||||
# list of beta arguments for sub-commands
|
||||
BETA_ARGS = {
|
||||
'config': ['jobs', ],
|
||||
|
@ -49,6 +51,10 @@ def check_beta(args_dict):
|
|||
# raise error.
|
||||
if not args_dict['beta']:
|
||||
cmd = args_dict['command']
|
||||
# first check if command is beta
|
||||
if cmd in BETA_COMMANDS:
|
||||
raise cdist.CdistBetaRequired(cmd)
|
||||
# then check if command's argument is beta
|
||||
if cmd in BETA_ARGS:
|
||||
for arg in BETA_ARGS[cmd]:
|
||||
if arg in args_dict and args_dict[arg]:
|
||||
|
|
Loading…
Reference in a new issue