diff --git a/cdist/__init__.py b/cdist/__init__.py index 9068ae69..b6f5c8cb 100644 --- a/cdist/__init__.py +++ b/cdist/__init__.py @@ -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 " - "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) + 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.") + 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): diff --git a/scripts/cdist b/scripts/cdist index 0acfe06c..9f8d326d 100755 --- a/scripts/cdist +++ b/scripts/cdist @@ -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]: