Exemple #1
0
def _retrieve_options() -> List[click.option]:

    return [
        click.option(
            "--results/--no-results",
            "include_results",
            default=False,
            help="Whether to also pull down any available results.",
            show_default=True,
        ),
        optgroup.group("Job submission",
                       help="Options for generating job submission scripts."),
        optgroup.option(
            "--conda-environment",
            default="forcebalance",
            type=click.STRING,
            help="The conda environment to run within.",
            show_default=True,
        ),
        optgroup.option(
            "--max-time",
            default="168:00",
            type=click.STRING,
            help="The maximum wall-clock time for submissions.",
            show_default=True,
        ),
        optgroup.group(
            "Evaluator configuration",
            help="Configuration options for the OpenFF Evaluator.",
        ),
        optgroup.option(
            "--preset",
            "evaluator_preset",
            default="lilac-dask",
            type=click.Choice(["lilac-dask", "lilac-local"],
                              case_sensitive=True),
            help="The present evaluator compute settings to use.",
            show_default=True,
        ),
        optgroup.option(
            "--port",
            "evaluator_port",
            default=8000,
            type=click.INT,
            help="The port to run the evaluator server on.",
            show_default=True,
        ),
        optgroup.option(
            "--workers",
            "n_evaluator_workers",
            default=1,
            type=click.INT,
            help="The target number of evaluator compute workers to spawn.\n"
            "\n"
            "The actual number may be less than this if the specified compute backend "
            "supports elastic scaling of workers depending on the amount of available "
            "work.",
            show_default=True,
        ),
    ]
Exemple #2
0
def _run_options():

    return [
        click.option(
            "--restart",
            default=False,
            type=click.BOOL,
            help=
            "Whether to restart the optimization from where it left off.\nIf "
            "false any existing results will be removed / overwritten.",
            show_default=True,
        ),
        optgroup.group(
            "Evaluator configuration",
            help="Configuration options for the OpenFF Evaluator.",
        ),
        optgroup.option(
            "--config",
            "server_config",
            default="server-config.json",
            type=click.Path(exists=False, dir_okay=False),
            help="The path to the OpenFF Evaluator server configuration file.",
            show_default=True,
        ),
    ]
Exemple #3
0
def add_logging_options(cmd: click.Command) -> click.Command:

    levels = ('TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')

    cmd = optgroup.option(
        '--log-level',
        type=click.Choice(levels, case_sensitive=False),
        help='Amount of detail in build-time logging output.')(cmd)
    cmd = optgroup('Logging')(cmd)

    return cmd
Exemple #4
0
def _run_options():

    return [
        click.option(
            "--restart",
            default=True,
            type=click.BOOL,
            help=
            "Whether to restart the optimization from where it left off.\nIf "
            "false any existing results will be removed / overwritten.",
            show_default=True,
        ),
        optgroup.group(
            "Evaluator configuration",
            help="Configuration options for the OpenFF Evaluator.",
        ),
        optgroup.option(
            "--config",
            "server_config",
            default="server-config.json",
            type=click.Path(exists=True, dir_okay=False),
            help="The path to the OpenFF Evaluator server configuration file.",
            show_default=True,
        ),
        optgroup.option(
            "--options",
            "request_options",
            default="estimation-options.json",
            type=click.Path(exists=True, dir_okay=False),
            help="The path to the OpenFF Evaluator request options.",
            show_default=True,
        ),
        optgroup.option(
            "--polling-interval",
            default=600,
            type=click.INT,
            help=
            "The interval with which to check the progress of the benchmark (s).",
            show_default=True,
        ),
    ]
Exemple #5
0
def _analyse_options() -> List[click.option]:

    return [
        optgroup.group(
            "Backwards compatibility",
            help="Options to allow for backwards compatibility with previous results.",
        ),
        optgroup.option(
            "--reindex",
            is_flag=True,
            default=False,
            help="Attempt to determine matching reference and estimated data points "
            "based on the state at which the property was measured, rather than by its "
            "unique id. This option is only to allow backwards compatibility with "
            "optimizations ran not using this framework, and should not be used in "
            "general.",
        ),
    ]
Exemple #6
0
    def wrapper(command):
        command = (
            click.option(
                "-b",
                "--backend",
                type=click.Choice(backend_names),
                required=True,
                help="Backend",
            )
        )(command)

        for backend_name in backend_names:
            backend_class = get_class_from_name(backend_name, backends)

            for parameter in signature(backend_class.__init__).parameters.values():
                if parameter.name == "self":
                    continue
                option = f"--{backend_class.name}-{parameter.name}".replace("_", "-")
                envvar = (
                    f"{ENVVAR_PREFIX}_{backend_class.name}_{parameter.name}".upper()
                )
                option_kwargs = {}
                # If the parameter is a boolean, convert it to a flag option
                if parameter.annotation is bool:
                    option = (
                        f"{option}/--no-{backend_class.name}-{parameter.name}".replace(
                            "_", "-"
                        )
                    )
                    option_kwargs["is_flag"] = True
                elif parameter.annotation is dict:
                    option_kwargs["type"] = CommaSeparatedKeyValueParamType()
                command = (
                    optgroup.option(
                        option,
                        envvar=envvar,
                        default=parameter.default,
                        **option_kwargs,
                    )
                )(command)
            command = (optgroup.group(f"{backend_class.name} backend"))(command)

        command = (cli.command(name=name or command.__name__))(command)
        return command
Exemple #7
0
def _plot_options() -> List[click.option]:

    return [
        click.argument(
            "directories",
            nargs=-1,
            type=click.Path(exists=True),
        ),
        optgroup.group(
            "Output",
            help="Options for saving the plots.",
        ),
        optgroup.option(
            "--file-type",
            type=click.Choice(["pdf", "png"]),
            default="pdf",
            show_default=True,
            help="The file type to save the plots as.",
        ),
    ]
Exemple #8
0
def add_build_options(cmd: click.Command) -> click.Command:
    """
    Decorator which adds all build-arguments to a click command
    """
    cmd = optgroup.option(
        '--distpath',
        default=DEFAULT_DISTPATH,
        type=click.Path(),
        help='Where to put the bundled app (default: ./dist)')(cmd)
    cmd = optgroup.option(
        '--workpath',
        default=DEFAULT_WORKPATH,
        type=click.Path(),
        help=
        'Where to put all the temporary work files - .log, .pyz, etc. (default: ./build)'
    )(cmd)
    cmd = optgroup.option(
        '-y',
        '--noconfirm',
        is_flag=True,
        default=False,
        help='Replace output directory without asking for confirmation')(cmd)
    cmd = optgroup.option(
        '--upx-dir',
        default=None,
        type=click.Path(),
        help='Path to UPX utility (default: search PATH)')(cmd)
    cmd = optgroup.option(
        '-a',
        '--ascii',
        is_flag=True,
        default=False,
        help='Don\'t include unicode support (default: included if available)'
    )(cmd)
    cmd = optgroup.option(
        '--clean',
        is_flag=True,
        default=False,
        help='Clean PyInstaller cache and remove temporary files before building'
    )(cmd)
    cmd = optgroup('Output Options', help='Help')(cmd)

    return cmd
Exemple #9
0
from click_skeleton import add_options
from click_skeleton.helpers import split_arguments

from musicbot.cli.options import (config_string, dry_option, sane_rating,
                                  sane_set)
from musicbot.defaults import (DEFAULT_ACOUSTID_API_KEY, DEFAULT_CHECKS,
                               DEFAULT_FLAT, DEFAULT_MAX_RATING,
                               DEFAULT_MIN_RATING)
from musicbot.file import File

logger = logging.getLogger(__name__)

music_options_group = optgroup('Music options')
keywords_option = optgroup.option(
    '--keywords',
    help='Keywords',
    multiple=True,
    callback=split_arguments,
)
artist_option = optgroup.option('--artist', help='Artist')
album_option = optgroup.option('--album', help='Album')
title_option = optgroup.option('--title', help='Title')
genre_option = optgroup.option('--genre', help='Genre')
track_option = optgroup.option('--track', help='Track number')
rating_option = optgroup.option(
    '--rating',
    help='Rating',
    type=click.FloatRange(DEFAULT_MIN_RATING, DEFAULT_MAX_RATING, clamp=True),
    callback=sane_rating,
)

keywords_arguments = click.argument(
Exemple #10
0
IGNORE_OPTION_LIST = [
    'image',
    'subscriber',
    'feature',
    'cron',
    'cron_schedule',
    'description',
]

# Those options would be passed to tipocket case,
# except those in IGNORE_OPTION_LIST.
COMMON_OPTIONS = (
    # !!! remember to update params.IGNORE_OPTION_LIST when
    # a parameter is modified
    optgroup.group('Test case deploy options'),
    optgroup.option('--subscriber', multiple=True),
    optgroup.option('--feature', default='universal'),
    optgroup.option('--image', default="pingcap/tipocket"),
    optgroup.option('--description', default=''),
    optgroup.option('--cron/--not-cron', default=False),
    optgroup.option('--cron-schedule', default='30 17 * * *'),
    optgroup.group('Test case common options'),
    optgroup.option('--round', default='1'),
    optgroup.option('--client', default='5'),
    optgroup.option('--run-time', default='10m'),
    optgroup.option('--wait-duration', default='10m'),
    optgroup.option('--nemesis', default=''),
    optgroup.option('--purge/--no-purge', default=True),
    optgroup.option('--delns/--no-delns', 'delNS', default=True),
    optgroup.group('TiDB cluster options'),
    optgroup.option('--namespace', default=''),
Exemple #11
0
def corgie_option(*args, **kwargs):
    return optgroup.option(*args, show_default=True, **kwargs)
Exemple #12
0
import click
from click_option_group import optgroup  # type: ignore
from click_skeleton import add_options

from musicbot.cli.options import sane_list
from musicbot.defaults import (DEFAULT_MAX_RATING, DEFAULT_MIN_RATING,
                               DEFAULT_RATINGS)

bests_options = add_options(
    optgroup.group("Bests options"),
    optgroup.option('--min-playlist-size',
                    help="Minimum size of playlist to write",
                    default=1),
    optgroup.option(
        '--rating',
        'ratings',
        help="Generate bests for those ratings",
        default=DEFAULT_RATINGS,
        type=click.FloatRange(DEFAULT_MIN_RATING,
                              DEFAULT_MAX_RATING,
                              clamp=True),
        multiple=True,
    ),
    optgroup.option('--types',
                    help="Type of bests playlists",
                    default=["genre", "keyword", "rating", "artist"],
                    multiple=True,
                    callback=sane_list),
)
Exemple #13
0
    ctx.params[param.name] = folders
    return folders


folder_argument = click.argument('folder',
                                 type=click.Path(
                                     path_type=Path,
                                     exists=True,
                                     file_okay=False,
                                 ))

folders_argument = add_options(
    dry_option, optgroup.group("Folders options"),
    optgroup.option(
        '--limit',
        help="Limit number of music files",
        type=int,
        is_eager=True,
    ),
    optgroup.option(
        '--extension',
        'extensions',
        help='Supported formats',
        default=sorted(DEFAULT_EXTENSIONS),
        multiple=True,
        callback=split_arguments,
        show_default=True,
        is_eager=True,
    ), click.argument(
        'folders',
        nargs=-1,
        callback=sane_folders,
Exemple #14
0
from click_option_group import optgroup, AllOptionGroup  # type: ignore
from musicbot import defaults
from musicbot.helpers import config_string

graphql_admin_option = optgroup.option(
    '--graphql-admin',
    help='GraphQL endpoint',
    default=defaults.DEFAULT_GRAPHQL_ADMIN,
    callback=config_string,
    show_default=True,
)

graphql_admin_user_option = optgroup.option(
    '--graphql-admin-user',
    help='GraphQL admin user (basic auth)',
    default=defaults.DEFAULT_GRAPHQL_ADMIN_USER,
    callback=config_string,
)

graphql_admin_password_option = optgroup.option(
    '--graphql-admin-password',
    help='GraphQL admin password (basic auth)',
    default=defaults.DEFAULT_GRAPHQL_ADMIN_PASSWORD,
    callback=config_string,
)

options = [
    optgroup.group('Admin options'),
    graphql_admin_option,
    optgroup.group('Basic auth', cls=AllOptionGroup),
    graphql_admin_user_option,
Exemple #15
0
from musicbot.config import (
    DEFAULT_COLOR,
    DEFAULT_CONFIG,
    DEFAULT_CRITICAL,
    DEFAULT_DEBUG,
    DEFAULT_ERROR,
    DEFAULT_INFO,
    DEFAULT_LOG,
    DEFAULT_QUIET,
    DEFAULT_WARNING
)

config_option = optgroup.option(
    '--config', '-c',
    help='Config file path',
    type=click.Path(readable=True, writable=True, dir_okay=False),
    envvar='MB_CONFIG',
    default=DEFAULT_CONFIG,
    show_default=True,
)

color_option = optgroup.option(
    '--color/--no-color',
    help='Enable or disable color in output',
    envvar='MB_COLOR',
    is_flag=True,
    default=DEFAULT_COLOR,
    show_default=True,
)

log_option = optgroup.option(
    '--log', '-l',
Exemple #16
0
        else:
            kwargs[field] = ctx.params[field]
        ctx.params.pop(field)

    if rating is not None:
        kwargs['min_rating'] = rating
        kwargs['max_rating'] = rating

    music_filter = MusicFilter(**kwargs)
    ctx.params[param.name] = music_filter
    return music_filter


shuffle_option = optgroup.option(
    '--shuffle',
    help='Randomize selection',
    default=DEFAULT_SHUFFLE,
    is_flag=True,
)

interleave_option = optgroup.option(
    '--interleave',
    help='Interleave tracks by artist',
    is_flag=True,
)

ordering_options = add_options(
    optgroup('Ordering options'),
    shuffle_option,
    interleave_option,
)
from click_option_group import optgroup, MutuallyExclusiveOptionGroup  # type: ignore
from click_skeleton import ExpandedPath
from musicbot import defaults

config_option = optgroup.option(
    '--config',
    '-c',
    help='Config file path',
    type=ExpandedPath(writable=True, dir_okay=False),
    envvar=defaults.MB_CONFIG,
    default=defaults.DEFAULT_CONFIG,
    show_default=True,
)

log_option = optgroup.option(
    '--log',
    '-l',
    help='Log file path',
    type=ExpandedPath(writable=True, dir_okay=False),
    envvar=defaults.MB_LOG,
    default=defaults.DEFAULT_LOG,
    show_default=True,
)

debug_option = optgroup.option(
    '--debug',
    help='Debug verbosity',
    envvar=defaults.MB_DEBUG,
    default=defaults.DEFAULT_DEBUG,
    is_flag=True,
)
Exemple #18
0
                 value: str | None) -> Spotify:
    if param.name:
        ctx.params[param.name] = value
    spotify_params = {}
    for field in fields_dict(Spotify):
        spotify_params[field] = ctx.params['spotify_' + field]
        ctx.params.pop('spotify_' + field)
    spotify = Spotify(**spotify_params)
    ctx.params['spotify'] = spotify
    return spotify


spotify_cache_path_option = optgroup.option(
    '--spotify-cache-path',
    help='Spotify cache path',
    type=ExpandedPath(writable=True, readable=True, dir_okay=False),
    envvar='MB_SPOTIFY_CACHE_PATH',
    default=DEFAULT_SPOTIFY_CACHE_PATH,
    callback=config_string,
)

spotify_scope_option = optgroup.option(
    '--spotify-scope',
    help='Spotify OAuth scopes, comma separated',
    envvar='MB_SPOTIFY_SCOPE',
    default=DEFAULT_SPOTIFY_SCOPE,
    callback=config_string,
)

spotify_redirect_uri_option = optgroup.option(
    '--spotify-redirect-uri',
    help='Spotify redirect URI',
Exemple #19
0
from typing import Any, Optional, List, Dict, Iterable, Iterator
import click
import acoustid  # type: ignore
import mutagen  # type: ignore
from slugify import slugify
from pydub import AudioSegment  # type: ignore
from click_option_group import optgroup  # type: ignore
from click_skeleton.helpers import mysplit
from musicbot import defaults
from musicbot.music.helpers import ensure


logger = logging.getLogger(__name__)

music_options_group = optgroup.group('Music options')
keywords_option = optgroup.option('--keywords', help='Keywords', multiple=True)
artist_option = optgroup.option('--artist', help='Artist')
album_option = optgroup.option('--album', help='Album')
title_option = optgroup.option('--title', help='Title')
genre_option = optgroup.option('--genre', help='Genre')
number_option = optgroup.option('--number', help='Track number')
rating_option = optgroup.option('--rating', help='Rating')

STOPWORDS = ['the', 'remaster', 'remastered', 'cut', 'part', 'version', 'mix', 'deluxe', 'edit', 'album', 'lp'] + list(map(str, range(1900, 2020)))
REPLACEMENTS = [['praxis', 'buckethead'], ['lawson-rollins', 'buckethead']]

keywords_argument = click.argument(
    'keywords',
    nargs=-1,
)
def sane_music_filter(
        ctx: click.Context, param: click.ParamType, value: Any) -> MusicFilter:  # pylint: disable=unused-argument
    kwargs = {}
    for field in attr.fields_dict(MusicFilter):
        kwargs[field] = ctx.params[field]
        ctx.params.pop(field)

    myfilter = MusicFilter(**kwargs)
    ctx.params[param.name] = myfilter
    return myfilter


shuffle_option = optgroup.option(
    '--shuffle',
    help='Randomize selection',
    default=defaults.DEFAULT_SHUFFLE,
    is_flag=True,
    is_eager=True,
)
interleave_option = optgroup.option(
    '--interleave',
    help='Interleave tracks by artist',
    is_flag=True,
)
ordering_options = [
    optgroup.group('Ordering options'),
    shuffle_option,
    interleave_option,
]

options = [
Exemple #21
0
def add_makespec_options(cmd: click.Command) -> click.Command:

    # Group: Where to search
    cmd = optgroup.option(
        '--additional-hooks-dir',
        'hookspath',
        multiple=True,
        type=click.Path(),
        help=
        'Additional path to search for hooks. This option can be used multiple times.'
    )(cmd)
    cmd = optgroup.option(
        '-p',
        '--paths',
        multiple=True,
        type=click.Path(),
        help='A path to search for imports (like using PYTHONPATH). '
        f'Multiple paths are allowed, separated by ``{os.pathsep}``, or '
        'use this option multiple times. Equivalent to '
        'supplying the ``pathex`` argument in the spec file.')(cmd)
    cmd = optgroup('Where to search')(cmd)

    # Group: What to bundle
    cmd = optgroup.option(
        '--runtime-hook',
        'runtime_hooks',
        multiple=True,
        type=click.File(),
        help='Path to a custom runtime hook file. A runtime hook is code that '
        'is bundled with the executable and is executed before any '
        'other code or module to set up special features of the runtime '
        'environment. This option can be used multiple times.')(cmd)
    cmd = optgroup.option(
        '--collect-metadata-recursive',
        multiple=True,
        metavar='MODULENAME',
        help=
        'Recursively collect all metadata from the specified package and it\'s dependencies. '
        'This option can be use multiple times.')(cmd)
    cmd = optgroup.option(
        '--collect-metadata',
        multiple=True,
        metavar='MODULENAME',
        type=click.UNPROCESSED,
        callback=lambda _, _p, value: [x for x in value if is_ident(x)],
        help='Collect all metadata from the specified package. '
        'This option can be use multiple times.')(cmd)
    cmd = optgroup.option(
        '--collect-all',
        multiple=True,
        metavar='MODULENAME',
        type=click.UNPROCESSED,
        callback=lambda _, _p, value: [x for x in value if is_ident(x)],
        help=
        'Collect all submodules, data files, metadata, and binaries from the specified package or module. '
        'This option can be use multiple times.')(cmd)
    cmd = optgroup.option(
        '--collect-binaries',
        multiple=True,
        metavar='MODULENAME',
        type=click.UNPROCESSED,
        callback=lambda _, _p, value: [x for x in value if is_ident(x)],
        help='Collect all binaries from the specified package or module. '
        'This option can be use multiple times.')(cmd)
    cmd = optgroup.option(
        '--collect-datas',
        multiple=True,
        metavar='MODULENAME',
        type=click.UNPROCESSED,
        callback=lambda _, _p, value: [x for x in value if is_ident(x)],
        help='Collect all data files from the specified package or module. '
        'This option can be use multiple times.')(cmd)
    cmd = optgroup.option(
        '--collect-submodules',
        multiple=True,
        metavar='MODULENAME',
        type=click.UNPROCESSED,
        callback=lambda _, _p, value: [x for x in value if is_ident(x)],
        help='Collect all submodules from the specified package or module. '
        'This option can be used multiple times.')(cmd)
    cmd = optgroup.option(
        '--excluded-import',
        'excludes',
        multiple=True,
        metavar='MODULENAME',
        type=click.UNPROCESSED,
        callback=lambda _, _p, value: [x for x in value if is_ident(x)],
        help=
        'Optional module (Python name) that will be ignored and not included, '
        'as if it was not found. This option can be used multiple times.')(cmd)
    cmd = optgroup.option(
        '-H',
        '--hidden-import',
        '--hiddenimport',
        'hiddenimports',
        multiple=True,
        metavar='MODULENAME',
        type=click.UNPROCESSED,
        callback=lambda _, _p, value: [x for x in value if is_ident(x)],
        help=
        'An import not visible in the code of the script(s) or it\'s dependencies. '
        'This option can be used multiple times.')(cmd)
    cmd = optgroup.option(
        '--add-binary',
        'binaries',
        multiple=True,
        type=click.UNPROCESSED,
        callback=validate_datas_or_binaries,
        metavar=f'SRC{os.pathsep}DEST',
        help=
        'Additional binary files to be added to the executable. See the `--add-data` '
        'option for more details. This option can be used multiple times.')(
            cmd)
    cmd = optgroup.option(
        '--add-data',
        'datas',
        multiple=True,
        type=click.UNPROCESSED,
        callback=validate_datas_or_binaries,
        metavar=f'SRC{os.pathsep}DEST',
        help=
        'Additional non-binary files or folders to be added to the executable. '
        'The path separator is platform specific, `os.pathsep` (which is `;` on '
        'Windows and `:` on most unix systems) is used. This option can be used '
        'multiple times.')(cmd)
    cmd = optgroup('What to bundle')(cmd)

    # Group: What to generate

    cmd = optgroup.option(
        '--upx-exclude',
        'upx_exclude',
        multiple=True,
        metavar='FILE',
        help=
        'Prevent a binary from being compressed when using upx. This is typically'
        ' used if upx corrupts certain binaries during compression. FILE is the '
        'filename of the binary without path. This option can be used multiple times.'
    )(cmd)
    cmd = optgroup.option(
        '--noupx',
        is_flag=True,
        default=False,
        help='Don\'t apply UPX regardless of availability')(cmd)
    cmd = optgroup.option(
        '-s',
        '--strip',
        is_flag=True,
        default=False,
        help=
        'Apply a symbol-table strip to the executable and shared libraries. '
        '(not recommended on Windows)')(cmd)
    cmd = optgroup.option(
        '-d',
        '--debug',
        multiple=True,
        type=click.Choice(['all', 'imports', 'bootloader', 'noarchive']),
        help=('Whether or not to build a debug version of your code. '
              'This option can be used multiple times to select '
              'several of the following items.\n\n'
              '- bootloader: enable the bootloader\'s logging feature, '
              '              which prints launch progress messages.\n\n'
              '- imports: specify the -v option to the bundled Python '
              'interpreter. See ``python --help -v`` for more information '
              'on the effects of this option.\n\n'
              '- noarchive: instead of storing all frozen Python source '
              'files inside the executable file, store them as files '
              'alongside it.'))(cmd)
    cmd = optgroup.option(
        '--splash',
        type=click.File(),
        help=
        '(EXPERIMENTAL) Add an splash screen with the image IMAGE_FILE to the application. '
        'The splash screen can display progress updates while unpacking.')(cmd)
    cmd = optgroup.option('--key',
                          metavar='KEY',
                          help='The key used to encrypt python bytecode')(cmd)
    cmd = optgroup.option(
        '-F/-D',
        '--onefile/--onedir',
        'onefile',
        default=False,
        help='Single file or single directory bundle (default: onedir)')(cmd)
    cmd = optgroup.option(
        '--specpath',
        type=click.Path(),
        default='.',
        help=
        'Folder to store the generated spec file in (default : current directory)'
    )(cmd)
    cmd = optgroup.option(
        '-n',
        '--name',
        type=click.STRING,
        required=False,
        metavar='NAME',
        help=
        'Name to assign to the bundled app and spec file (default: first script\'s basename)'
    )(cmd)
    cmd = optgroup('What to generate')(cmd)

    return cmd
            logger.debug(f"{field} param not in options")
            continue
        kwargs[field] = ctx.params[field]
        ctx.params.pop(field)

    link_options = LinkOptions(**kwargs)
    ctx.params[param.name] = link_options
    return link_options


link_options_options = add_options(
    optgroup('Link options'),
    optgroup.option(
        '--http/--no-http',
        help="Generate HTTP link",
        is_flag=True,
        default=DEFAULT_HTTP,
        show_default=True,
    ),
    optgroup.option(
        '--sftp/--no-sftp',
        help="Generate sFTP link",
        is_flag=True,
        default=DEFAULT_SFTP,
        show_default=True,
    ),
    # optgroup.option(
    #     '--youtube/--no-youtube',
    #     help="Generate YouTube link",
    #     is_flag=True,
    #     default=DEFAULT_YOUTUBE,
Exemple #23
0
import click
from click_option_group import optgroup  # type: ignore
from click_skeleton import add_options

from musicbot.cli.options import config_string
from musicbot.musicdb import MusicDb


def sane_musicdb(ctx: click.Context, param: click.Parameter, value: str) -> MusicDb:
    if param.name:
        ctx.params[param.name] = value
    dsn = ctx.params.pop('dsn')
    musicdb = MusicDb.from_dsn(dsn)
    ctx.params['musicdb'] = musicdb
    return musicdb


musicdb_options = add_options(
    optgroup('MusicDB options'),
    optgroup.option(
        '--dsn',
        help='DSN to MusicBot EdgeDB',
        callback=config_string,
    ),
    optgroup.option(
        '--musicdb',
        expose_value=False,
        callback=sane_musicdb,
    ),
)
Exemple #24
0
    graphql = ctx.params.pop('graphql')
    email = ctx.params.pop('email')
    password = ctx.params.pop('password')
    if value:
        user = User.from_token(graphql=graphql, token=value)
    elif email and password:
        user = User.from_auth(graphql=graphql, email=email, password=password)
    else:
        raise FailedAuthentication("Either token or email/password must be given")
    ctx.params['user'] = user
    return user


token_option = optgroup.option(
    '--token', '-t',
    help='User token',
    expose_value=False,
    callback=sane_user,
)

email_option = optgroup.option(
    '--email', '-e',
    help='User email',
    default=defaults.DEFAULT_EMAIL,
    is_eager=True,
    callback=config_string,
)

password_option = optgroup.option(
    '--password', '-p',
    help='User password',
    default=defaults.DEFAULT_PASSWORD,