def inner(**kwargs): relevant_options = [ value for name, value in kwargs.items() if name in options ] if not only_one(*relevant_options): raise click.UsageError( "Illegal usage: `at least one, and only one of the options [{options}] is required` " .format(options=",".join("--" + op_name for op_name in options))) func(**kwargs)
def inner(**kwargs): relevant_options = [ value for name, value in kwargs.items() if name in dependents ] if any(relevant_options) and kwargs.get(root) is None: raise click.UsageError( "Illegal usage: `in oprder to use any of this options {options}, " "the {root} option must be set".format(root=root, options=dependents)) func(**kwargs)
def handle_parse_result(self, ctx, opts, args): we_are_present = self.name in opts other_present = self.not_required_if in opts if other_present: if we_are_present: raise click.UsageError( "Illegal usage: `%s` is mutually exclusive with `%s`" % (self.name, self.not_required_if)) else: self.prompt = None return super(NotRequiredIf, self).handle_parse_result(ctx, opts, args)
def inner(**kwargs): relevant_options = [ value for name, value in kwargs.items() if name in dependents ] if any(relevant_options) and not kwargs.get(root): raise click.UsageError( "Illegal usage: In-order to use any of those options {options}, " "the `{root}` option must be set".format( root=root, options=dependents ) ) func(**kwargs)