Exemple #1
0
    def get_click_options(self):
        import q2cli
        import q2cli.util

        if self.type is bool:
            no_name = self.prefix + 'no_' + self.name
            cli_no_name = q2cli.util.to_cli_name(no_name)
            name = '--' + self.cli_name + '/--' + cli_no_name
            # click.Option type is determined implicitly for flags with
            # secondary options, and explicitly passing type=bool results in a
            # TypeError, so we pass type=None (the default).
            option_type = None
        else:
            name = '--' + self.cli_name
            option_type = self.type

        if self.default is NoDefault:
            requirement = '[required]'
        elif self.default is None:
            requirement = '[optional]'
        else:
            requirement = '[default: %s]' % self.default

        # Pass `default=None` and `show_default=False` to `click.Option`
        # because the handlers are responsible for resolving missing values and
        # supplying defaults. Telling Click about the default value here makes
        # it impossible to determine whether the user supplied or omitted a
        # value once the handlers are invoked.
        option = q2cli.Option([name],
                              type=option_type,
                              default=None,
                              show_default=False,
                              help='')

        yield self._add_description(option, requirement)
Exemple #2
0
    def get_click_options(self):
        import click
        import q2cli

        yield q2cli.Option(['--' + self.cli_name],
                           type=click.Path(exists=True,
                                           dir_okay=False,
                                           file_okay=True,
                                           readable=True),
                           help='Use config file for command options')
Exemple #3
0
    def get_click_options(self):
        import click
        import q2cli

        yield q2cli.Option(['--' + self.cli_name],
                           type=click.Path(exists=False,
                                           dir_okay=True,
                                           file_okay=False,
                                           writable=True),
                           help='Output unspecified results to a directory')
Exemple #4
0
    def get_click_options(self):
        import q2cli

        type = q2cli.core.ResultPath(self.repr,
                                     exists=False,
                                     file_okay=True,
                                     dir_okay=False,
                                     writable=True)
        option = q2cli.Option(['--' + self.cli_name], type=type, help="")
        yield self._add_description(option,
                                    '[required if not passing --output-dir]')
Exemple #5
0
    def get_click_options(self):
        import q2cli

        # `is_flag` will set the default to `False`, but `self._locate_value`
        # needs to distinguish between the presence or absence of the flag
        # provided by the user.
        yield q2cli.Option(['--' + self.cli_name],
                           is_flag=True,
                           default=None,
                           help='Silence output if execution is successful '
                           '(silence is golden).  [default: %s]' %
                           self.default)
Exemple #6
0
    def get_click_options(self):
        import q2cli

        # `is_flag` will set the default to `False`, but `self._locate_value`
        # needs to distinguish between the presence or absence of the flag
        # provided by the user.
        yield q2cli.Option(
            ['--' + self.cli_name],
            is_flag=True,
            default=None,
            help='Display verbose output to stdout and/or stderr during '
            'execution of this action.  [default: %s]' % self.default)
Exemple #7
0
    def get_click_options(self):
        import q2cli
        import q2cli.core

        type = q2cli.core.ResultPath(repr=self.repr,
                                     exists=True,
                                     file_okay=True,
                                     dir_okay=False,
                                     readable=True)
        if self.default is None:
            requirement = '[optional]'
        else:
            requirement = '[required]'

        option = q2cli.Option(['--' + self.cli_name], type=type, help="")
        yield self._add_description(option, requirement)
Exemple #8
0
    def get_click_options(self):
        import q2cli

        name = '--' + self.cli_name
        type = str
        help = 'Column from metadata file or artifact viewable as metadata.'

        if self.default is None:
            requirement = '[optional]'
        else:
            requirement = '[required]'

        option = q2cli.Option([name], type=type, help=help, metavar=self.repr)

        yield from self.metadata_handler.get_click_options()
        yield self._add_description(option, requirement)
Exemple #9
0
    def get_click_options(self):
        import click
        import q2cli
        import q2cli.core

        name = '--' + self.cli_name
        type = click.Path(exists=True,
                          file_okay=True,
                          dir_okay=False,
                          readable=True)
        type = q2cli.core.MultipleType(type)
        help = ('Metadata file or artifact viewable as metadata. This '
                'option may be supplied multiple times to merge metadata.')

        if self.default is None:
            requirement = '[optional]'
        else:
            requirement = '[required]'

        option = q2cli.Option([name], type=type, help=help, multiple=True)
        yield self._add_description(option, requirement)