Ejemplo n.º 1
0
def dump_script(shell: str) -> None:
    """Dump the script content."""
    # todo resolve actual script name in case user aliased it
    prog_name = "hass-cli"
    cvar = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper()

    click.echo(get_completion_script(prog_name, cvar, shell))
Ejemplo n.º 2
0
def test_zsh_func_name():
    from click._bashcomplete import get_completion_script

    script = get_completion_script("foo-bar", "_COMPLETE_VAR", "zsh").strip()
    assert script.startswith("#compdef foo-bar")
    assert "compdef _foo_bar_completion foo-bar;" in script
    assert "(( ! $+commands[foo-bar] )) && return 1" in script
Ejemplo n.º 3
0
def test_bash_func_name():
    from click._bashcomplete import get_completion_script

    script = get_completion_script("foo-bar baz_blah", "_COMPLETE_VAR",
                                   "bash").strip()
    assert script.startswith("_foo_barbaz_blah_completion()")
    assert "_COMPLETE_VAR=complete $1" in script
def dump_script(shell: str) -> None:
    """Dump the script content."""
    # todo resolve actual script name in case user aliased it
    prog_name = "hass-cli"
    cvar = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper()

    click.echo(get_completion_script(prog_name, cvar, shell))
Ejemplo n.º 5
0
def prepare_zshrc(pm_path):
    click.echo("zsh detected")
    zsh_autocomplete_path = os.path.join(pm_path, ".zsh-autocomplete.sh")
    with open(zsh_autocomplete_path, "w") as f:
        f.write(get_completion_script("pm", "_PM_COMPLETE", "zsh"))

    zshrc_path = os.path.expanduser("~/.zshrc")
    lines = [
        f'export PM_PATH="{pm_path}"',
        f". {zsh_autocomplete_path}",
    ]
    if click.confirm("Do you want pm to update your zshrc ?"):
        update_rc(zshrc_path, lines)
    else:
        click.echo("Add this to your zshrc to enable pm")
        click.echo("\n".join(lines))
Ejemplo n.º 6
0
def test_bash_func_name():
    from click._bashcomplete import get_completion_script
    script = get_completion_script('foo-bar baz_blah', '_COMPLETE_VAR', 'bash').strip()
    assert script.startswith('_foo_barbaz_blah_completion()')
    assert '_COMPLETE_VAR=complete $1' in script
Ejemplo n.º 7
0
def completion(shell):
    """Autocomplete for bash"""
    click.echo(get_completion_script('zbuilder', '_ZBUILDER_COMPLETE', shell))
Ejemplo n.º 8
0
def test_bash_func_name():
    from click._bashcomplete import get_completion_script
    script = get_completion_script('foo-bar baz_blah', '_COMPLETE_VAR').strip()
    assert script.startswith('_foo_barbaz_blah_completion()')
    assert '_COMPLETE_VAR=complete $1' in script
Ejemplo n.º 9
0
def get_completions(shell: str = "bash") -> str:
    return get_completion_script("clinja", "_CLINJA_COMPLETE", shell)
Ejemplo n.º 10
0
def test_zsh_func_name():
    from click._bashcomplete import get_completion_script
    script = get_completion_script('foo-bar', '_COMPLETE_VAR', 'zsh').strip()
    assert script.startswith('#compdef foo-bar')
    assert 'compdef _foo_bar_completion foo-bar;' in script
    assert '(( ! $+commands[foo-bar] )) && return 1' in script