Ejemplo n.º 1
0
_console = Console(theme=rich_theme)
_LOGGER = get_rich_logger(__name__)
_HELP = Help(
    name='config',
    brief=f'Manage the {_PROG} configuration file.',
    synopsis=f'\t{_PROG} config set <key> <value>\n'
             f'\t{_PROG} config get <key>\n'
             f'\t{_PROG} config delete <key>'
             f'\t{_PROG} config list'
             f'\t{_PROG} config edit'
             f'\n\n'
             f'\t[h2]aliases:[/h2] {_PROG} c',
    description='This command provides a means of managing {_PROG}\'s .{_PROG}rc file. This '
                'allows for setting, getting, or updating the contents within the .{_PROG}rc.',
    sub_commands='Config supports the following sub-commands:'
                 '\n\n'
                 '[h2]set[/h2]\n'
                 f'\t[example]{_PROG} config set <key> <value>[/]\n'
                 '\tSets the config key to the value.\n'
                 '\tIf the value is omitted, it\'s set to "true".\n\n'
                 '[h2]get[/h2]\n'
                 f'\t[example]{_PROG} config get <key>[/]\n'
                 '\tPrints the config key value to stdout.\n\n'
                 '[h2]list[/h2]\n'
                 f'\t[example]{_PROG} config list[/]\n'
                 '\tPrints all of the config settings to stdout.\n\n'
                 '[h2]delete[/h2]\n'
                 f'\t[example]{_PROG} config delete <key>[/]\n'
                 '\tDeletes the key from the configuration file.\n\n'
)

Ejemplo n.º 2
0
_HELP = Help(
    name='outdated',
    brief='Show extensions that can be updated',
    synopsis=f'{_PROG} outdated\n'
             f'{_PROG} outdated [[<extension> ...]]\n'
             f'{_PROG} outdated [[<extension> ...]] [[--<editor>]]\n'
             f'{_PROG} outdated [[--<editor>]]\n'
             f'{_PROG} outdated [[--editors]]\n'
             f'{_PROG} outdated [[--all-editors]]\n\n'
             f'[h2]aliases:[/h2] {_PROG} dated, {_PROG} old\n',
    description='This command will check the VSCode Marketplace to see if any (or, specific) '
                'installed extensions have releases that are newer than the local versions.'
                '\n\n'
                'It also provides the ability to check if any (or, specific) supported code '
                'editors that have releases that are newer than the local versions.'
                '\n\n'
                'It will then print a list of results to stdout to indicate which extensions '
                '(and/or editors) have remote versions that are newer than the installed versions.'
                '\n\n'
                'This command will not ever actually download or install anything. It\'s '
                'essentially a peek or dry-run to see what could be updated.',
    options='[h2]--<editor>[/]\n'
            '\t* Type: Code Editor {{{}}}\n'
            '\t* Default: code'
            '\n\n'
            'Sets the context for which Code Editor the outdated extensions check is for. If no '
            'extensions are specified, the [command]outdated[/] command will check all of the '
            'extensions installed to the specified Code Editor. If any extensions are specified, '
            'the [command]outdated[/] command will check for newer remote versions for only the '
            'specified extensions.'
            '\n\n'
            '[h2]--editors[/]'
            '\n\n'
            'If set, the [command]outdated[/] command will check for newer remote versions of '
            'Code Editors instead of extensions. This option will only check for newer versions '
            'of Code Editors that are currently installed.'
            '\n\n'
            '[h2]--all-editors[/]'
            '\n\n'
            'Similarly to [command]--editors[/], this option will check for newer remote versions '
            'of Code Editors instead of extensions. Unlike [command]--editors[/], this option '
            'will check for newer versions of all supported Code Editors, not just those that '
            'are currently installed.'.format('|'.join(_AVAILABLE_EDITOR_KEYS))
)
Ejemplo n.º 3
0
from pyvem._help import Help
from pyvem._logging import get_rich_logger

_FUZZY_SORT_CONFIDENCE_THRESHOLD = 85
_AVAILABLE_EDITOR_KEYS = SupportedEditorCommands.keys()
_AVAILABLE_EDITOR_VALUES = SupportedEditorCommands.values()

_console = Console(theme=rich_theme)
_LOGGER = get_rich_logger(__name__)
_HELP = Help(
    name='list',
    brief='List installed extension(s)',
    synopsis=f'{_PROG} list (with no args, show all installed extensions\n'
             '\t\t  for all installed, supported code editors) \n'
             f'{_PROG} list [[<extension>]]\n'
             f'{_PROG} list [[--<editor>]]\n\n'
             f'[h2]aliases[/]: {_PROG} ls, {_PROG} ll, {_PROG} la',
    description='This command will print to stdout all of the versions of '
                'extensions that are installed. If an editor name is '
                'provided, the output will be scoped to only print the '
                'versions of extensions installed to that particular editor.'
)


class ListCommand(Command):
    """
    The ListCommand class defines the "list" command. This class
    inherits from the base Command class.
    """

    def __init__(self, name, aliases=None):
Ejemplo n.º 4
0
"""Info command implementation"""

from pyvem._command import Command
from pyvem._config import _PROG
from pyvem._help import Help
from pyvem._logging import get_rich_logger

_LOGGER = get_rich_logger(__name__)
_HELP = Help(
    name='info',
    brief='Show extension details',
    synopsis=f'{_PROG} info <extension>\n'
    f'{_PROG} info <extension>[[@<version>]]\n\n'
    f'[h2]aliases[/]: {_PROG} show, {_PROG} view',
    description=
    'This command shows data about an extension from the VSCode Marketplace. '
    'The default extension version is "latest", unless otherwise specified. '
    'The info command accepts 1+ extension at a time.')


class InfoCommand(Command):
    """
    The InfoCommand class defines the "info" command. This class
    inherits from the base Command class.
    """
    def __init__(self, name, aliases=None):
        super().__init__(name, _HELP, aliases=aliases or [])

    def get_command_parser(self, *args, **kwargs):
        """
        No custom command parser implementation is needed for the Info command.
Ejemplo n.º 5
0
_HELP = Help(
    name='update',
    brief='Update extension(s) and editor(s)',
    synopsis=f'{_PROG} update\n'
             f'{_PROG} update [[<extension-1>..<extension-N>]]\n'
             f'{_PROG} update [[--<editor>]]\n'
             f'{_PROG} update [[--no-editor]]\n'
             f'{_PROG} update [[--all]]\n\n'
             f'[h2]aliases[/]: {_PROG} up, {_PROG} upgrade, {_PROG} u',
    description= \
        'This command will update extensions to the latest versions. If an '
        'explicit extension is passed to the [example]update[/] command and '
        'the extension is not yet installed, this command will install the '
        'extension.'
        '\n\n'
        'If no arguments are provided to the [example]update[/] command, '
        f'{_PROG} will default to updating all extensions for the current '
        'VSCode installation.'
        '\n\n'
        'To update all extensions for a different version of VSCode instead, '
        'provide a [example]--<editor>[/] option to the [example]update[/] '
        'command. For example, to update all the extensions for VSCode '
        'Insiders, use:'
        '\n\t'
        f'[example]{_PROG} update --insiders[/]'
        '\n\n'
        f'By default, {_PROG} will also look for an update to the code '
        'editor. In order to bypass this check, the [example]--no-editor[/] '
        'option can be provided.'
        '\n\n'
        'To check for updates for all of the installed code editors on your '
        'system as well as all of their extensions, use:'
        '\n\t'
        f'[example]{_PROG} update --all[/]'
)
Ejemplo n.º 6
0
"""Version command implementation"""

import sys

from pyvem._command import Command
from pyvem._config import _PROG, _VERSION
from pyvem._help import Help
from pyvem._logging import get_rich_logger

_LOGGER = get_rich_logger(__name__)
_HELP = Help(name='version',
             brief=f'shows the {_PROG} version',
             synopsis=f'{_PROG} -V\n'
             f'{_PROG} --version\n\n'
             f'[h2]aliases[/]: {_PROG} version',
             description=
             f'This command will print the current {_PROG} version to stdout.')


class VersionCommand(Command):
    """
    The VersionCommand class defines the "version" command. This class
    inherits from the base Command class.
    """
    def __init__(self, name, aliases=None):
        super().__init__(name, _HELP, aliases=aliases or [])

    def get_command_parser(self, *args, **kwargs):
        pass

    def run(self, *args, **kwargs):
Ejemplo n.º 7
0
from pyvem.commands.install import install_command
from pyvem.commands.list import list_command
from pyvem.commands.outdated import outdated_command
from pyvem.commands.search import search_command
from pyvem.commands.update import update_command
from pyvem.commands.version import version_command

_LOGGER = get_rich_logger(__name__)
_HELP = Help(
    name='help',
    brief='Show help documentation',
    synopsis=f'{_PROG} help <command>',
    description= \
        f'This command will show help documentation for other {_PROG} '
        f'commands. If the provided [keyword]<command>[/keyword] is not valid '
        'or no help documentation exists, the help command will display:'
        '\n\t'
        '[example]No help documentation is available for the command '
        '[keyword]<command>[/][/]'
        '\n\n'
        'If no command (or no valid command) is passed to the [example]help[/] '
        f'command, then {_PROG}\'s default help output is printed to stdout.'
)


class HelpCommand(Command):
    """
    Inherits from the base Command class and overrides the `run` method
    to implement the Help functionality.
    """
    def __init__(self, name, aliases=None):
Ejemplo n.º 8
0
_LOGGER = get_rich_logger(__name__, console=_console)

_HELP = Help(
    name='search',
    brief='Search the VSCode Marketplace',
    synopsis=f'{_PROG} search <term>\n'
    f'{_PROG} search <term> [[--sort-by [[COLUMN]]]]\n'
    f'{_PROG} search <term> [[--count [[NUMBER]]]]\n\n'
    f'[h2]aliases:[/h2] {_PROG} s, {_PROG} find\n',
    description=
    'This command searched the VSCode Marketplace for extensions matching the '
    'provided search terms. Additional search control is provided by specifying '
    'sorting options and/or specifying the amount of results to display.',
    options='[h2]--sort-by [[COLUMN]][/h2]\n'
    '\t* Type: String\n'
    '\t* Default: Relevance'
    '\n\n'
    'Sort the search results in descending order, based on a particular column value. '
    f'{_PROG} uses fuzzy matching to check if the provided [bold]--sort-by[/bold] value '
    'matches any of the known sort columns.'
    '\n\n'
    'Available sort columns include:\n'
    f'[example]{", ".join(_AVAILABLE_SORT_COLUMNS)}[/]'
    '\n\n'
    '[h2]--count [[NUMBER]][/h2]\n'
    '\t* Type: Integer\n'
    '\t* Default: 15'
    '\n\n'
    'By default, up to 15 results are returned, but this default may be overriden to '
    'specify how many search results should be returned.')

Ejemplo n.º 9
0
_console = Console(theme=rich_theme)
_LOGGER = get_rich_logger(__name__)
_HELP = Help(
    name='update',
    brief='Update extension(s) and editor(s)',
    synopsis=f'{_PROG} update\n'
    f'{_PROG} update [[<extension-1>..<extension-N>]]\n'
    f'{_PROG} update [[--<editor>]]\n'
    f'{_PROG} update [[--no-editor]]\n'
    f'{_PROG} update [[--all]]\n\n'
    f'[h2]aliases[/]: {_PROG} up, {_PROG} upgrade',
    description=
    'This command will update extensions to their latest versions. If an explicit '
    'extension is passed to the [example]update[/] command and the extension is not '
    'yet installed, this command will install the extension.'
    '\n\n'
    f'If no arguments are provided to the [example]update[/] command, `{_PROG}` will '
    'default to updating all extensions for the current VSCode installation.\n'
    'In order to update all extensions for a different version of VSCode, instead, '
    'provide a `--<editor>` option to the `update` command. For example, to update all '
    'the extensions for VSCode Insiders, use the following command:\n'
    f'\t[example]{_PROG} update --insiders[/]'
    '\n\n'
    f'By default, {_PROG} will also look for an update to the code editor. In order '
    'to bypass this check, the [example]--no-editor[/] option can be provided.'
    '\n\n'
    'In order to check for update to all of the installed code editor on the local '
    'system as well as all of their extensions, use:\n'
    f'\t[example]{_PROG} update --all[/]')

Ejemplo n.º 10
0
# pylint: disable=unused-import
from pyvem.commands.config import config_command
from pyvem.commands.help import help_command
from pyvem.commands.info import info_command
from pyvem.commands.install import install_command
from pyvem.commands.list import list_command
from pyvem.commands.outdated import outdated_command
from pyvem.commands.search import search_command
from pyvem.commands.update import update_command
from pyvem.commands.version import version_command

_LOGGER = get_rich_logger(__name__)
_HELP = Help(
    name='commands',
    brief=f'Lists the supported {_PROG} commands',
    synopsis='',
    description=f'For detailed information about a specific command, use'
    f'[example]{_PROG} help <command>[/example]')


class CommandsCommand(Command):
    """
    The CommandsCommand class defines the "commands" command. This class
    inherits from the base Command class.
    """
    def __init__(self, name, aliases=None):
        super().__init__(name, _HELP, aliases=aliases or [])
        self.is_hidden = True

    def get_command_parser(self, *args, **kwargs):
        pass
Ejemplo n.º 11
0
_LOGGER = get_rich_logger(__name__)

_HELP = Help(
    name='install',
    brief='Install extension(s) or editor(s)',
    synopsis=
    f'{_PROG} install (with no args, installs any .vsix in the current directory)\n'
    f'{_PROG} install <editor>\n'
    f'{_PROG} install <publisher>.<package>\n'
    f'{_PROG} install <publisher>.<package>[[@<version>]]\n'
    f'{_PROG} install </path/to/*.vsix>\n'
    f'{_PROG} install </path/to/directory>\n\n'
    f'[h2]aliases[/]: {_PROG} i, {_PROG} add\n'
    '[h2]common options[/]: [[-s, --source EDITOR]] [[-t, --target EDITOR]]\n'
    '\t\t\t\t[[--insiders]] [[--exploration]] [[--codium]]',
    description=
    'This command installs an extension as well as any extensions that it depends on. '
    'This command can also be used to install any of the supported code editors.'
    '\n\n'
    'One or more extensions may be provided to the install command, using a '
    f'space-delimited list [example](e.g. {_PROG} install <ext1> <ext2>)[/]'
    '\n\n'
    'Notice in the synopsis that an extension is specified by both its publisher name '
    'and package name. Together, these make up the extension\'s unique id, which '
    'helps identify it within the VSCode Marketplace.'
    '\n\n'
    f'If a local file-system path is provided, {_PROG} will attempt to install the '
    'extension(s) at the provided path. Otherwise, the `install` command involves '
    'making a remote request to the VSCode Marketplace to download the .vsix '
    'extension(s).')