コード例 #1
0
 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)
コード例 #2
0
        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)
コード例 #3
0
ファイル: cli.py プロジェクト: turbaszek/dbnd
    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)
コード例 #4
0
ファイル: cli.py プロジェクト: kalebinn/dbnd
        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)