Example #1
0
    def decorator(f):
        option_attrs = attrs.copy()

        if "help" in option_attrs:
            option_attrs["help"] = inspect.cleandoc(option_attrs["help"])
        OptionClass = option_attrs.pop("cls", CustomOption)
        _param_memo(f, OptionClass(param_decls, **option_attrs))
        return f
    def decorator(f: _C) -> _C:
        ArgumentClass = attrs.pop("cls", click.Argument)
        argument = ArgumentClass(param_decls, **attrs)
        _param_memo(f, argument)

        _get_default_from_callback_and_set(f, argument)

        return f
Example #3
0
 def decorator(f):
     _param_memo(
         f,
         click.Option(['-h', '--help'],
                      help='Print this message & exit with status zero',
                      is_flag=True,
                      is_eager=True,
                      expose_value=False,
                      callback=_shim))
     return f
    def decorator(f):
        # Copy attrs, so pre-defined parameters can re-use the same cls=
        option_attrs = attrs.copy()

        if "help" in option_attrs:
            option_attrs["help"] = inspect.cleandoc(option_attrs["help"])

        OptionClass = option_attrs.pop("cls", PrettyOption)
        _param_memo(f, OptionClass(param_decls, **option_attrs))
        return f
    def decorator(f):
        # Copy attrs, so pre-defined parameters can re-use the same cls=
        arg_attrs = attrs.copy()

        if "help" in arg_attrs:
            arg_attrs["help"] = inspect.cleandoc(arg_attrs["help"])

        ArgumentClass = arg_attrs.pop("cls", PrettyArgument)
        _param_memo(f, ArgumentClass(param_decls, **arg_attrs))
        return f
Example #6
0
    def add_config_option(cmd):
        """Add ``--config`` option on a command

        :param cmd: command to add --config option on
        :type cmd: :class:`click.Command`
        """
        if isinstance(
                cmd, click.Command
        ) and config_option not in cmd.params:  # pragma: no branch
            _param_memo(cmd, config_option)
            cmd.invoke = with_config_path(cmd.invoke)
Example #7
0
    def decorator(f):
        # Issue 926, copy attrs, so pre-defined options can re-use the same cls=
        option_attrs = attrs.copy()

        if 'help' in option_attrs:
            option_attrs['help'] = inspect.cleandoc(option_attrs['help'])
        OptionClass = option_attrs.pop('cls', Option)
        opt = OptionClass(param_decls, **option_attrs)
        _param_memo(f, opt)
        if 'envvar' in attrs:
            e = attrs['envvar']
            all_envs[e] = opt
        return f
Example #8
0
        def decorator(func):
            self = cls()
            for key, option in sorted(self._options.items()):
                if enable.get(key, option.enabled):
                    _param_memo(func, option)

            @wraps(func)
            def wrapper(*args, **kwargs):
                ctx = get_current_context()
                ctx.ensure_object(cls)
                return func(*args, **kwargs)

            return wrapper
    def decorator(f: _C) -> _C:
        option_attrs = attrs.copy()

        if "help" in option_attrs:
            option_attrs["help"] = inspect.cleandoc(option_attrs["help"])

        OptionClass = option_attrs.pop("cls", click.Option)

        option = OptionClass(param_decls, **option_attrs)
        _param_memo(f, option)

        _get_default_from_callback_and_set(f, option)

        return f
Example #10
0
 def decorator(f):
     if "help" in attrs:
         attrs["help"] = inspect.cleandoc(attrs["help"])
     _param_memo(f, HiddenOption(param_decls, **attrs))
     return f
Example #11
0
 def decorator(f):
     _param_memo(f, GandiOption(param_decls, **attrs))
     return f
Example #12
0
 def decorator(f):
     if 'help' in attrs:
         attrs['help'] = inspect.cleandoc(attrs['help'])
     ArgumentClass = attrs.pop('cls', Argument)
     _param_memo(f, ArgumentClass(param_decls, **attrs))
     return f
Example #13
0
	def decorator(f):
		if 'help' in attrs:
			attrs['help'] = inspect.cleandoc(attrs['help'])
		_param_memo(f, HiddenOption(param_decls, **attrs))
		return f
Example #14
0
 def decorator(f):
     _param_memo(f, GandiOption(param_decls, **attrs))
     return f
Example #15
0
 def __call__(self, f):
     # this is the decorator call which registers options in reverse order
     if self.with_rollback:
         _param_memo(
             f,
             click.Option(
                 ("--rollback", ),
                 is_flag=True,
                 help="Rollback the transaction even if the script "
                 "does not raise an exception. Note that if the "
                 "script itself commits, this option has no effect. "
                 "This is why it is not named dry run. This option "
                 "is implied when an interactive console is "
                 "started.",
             ),
         )
     _param_memo(
         f,
         click.Option(
             ("--logfile", ),
             type=click.Path(dir_okay=False),
             help="Specify the log file.",
         ),
     )
     _param_memo(
         f,
         click.Option(
             ("--log-level", ),
             default=self.default_log_level,
             show_default=True,
             help="Specify the logging level. Accepted values depend "
             "on the Odoo version, and include debug, info, "
             "warn, error.",
         ),
     )
     if self.with_database:
         _param_memo(
             f,
             click.Option(
                 ("--database", "-d"),
                 envvar=["PGDATABASE"],
                 help="Specify the database name. If present, this "
                 "parameter takes precedence over the database "
                 "provided in the Odoo configuration file.",
             ),
         )
     if self.with_addons_path:
         _param_memo(
             f,
             click.Option(
                 ("--addons-path", ),
                 envvar=["ODOO_ADDONS_PATH"],
                 help="Specify the addons path. If present, this "
                 "parameter takes precedence over the addons path "
                 "provided in the Odoo configuration file.",
             ),
         )
     _param_memo(
         f,
         click.Option(
             ("--config", "-c"),
             envvar=["ODOO_RC", "OPENERP_SERVER"],
             type=click.Path(exists=True, dir_okay=False),
             callback=self._register,
             help="Specify the Odoo configuration file. Other "
             "ways to provide it are with the ODOO_RC or "
             "OPENERP_SERVER environment variables, "
             "or ~/.odoorc (Odoo >= 10) "
             "or ~/.openerp_serverrc.",
         ),
     )
     return f