Esempio n. 1
0
def test_man_completion(monkeypatch, tmpdir, xonsh_builtins):
    tempdir = tmpdir.mkdir('test_man')
    monkeypatch.setitem(os.environ, 'MANPATH', os.path.dirname(os.path.abspath(__file__)))
    xonsh_builtins.__xonsh_env__.update({'XONSH_DATA_DIR': str(tempdir)})
    completions = complete_from_man('--', 'yes --', 4, 6, __xonsh_env__)
    assert ('--version' in completions)
    assert ('--help' in completions)
Esempio n. 2
0
def test_man_completion():
    if ON_WINDOWS:
        raise SkipTest
    with tempfile.TemporaryDirectory() as tempdir:
        with mock_xonsh_env({'XONSH_DATA_DIR': tempdir}):
            completions = complete_from_man('--', 'yes --', 4, 6, __xonsh_env__)
        assert_true('--version' in completions)
        assert_true('--help' in completions)
Esempio n. 3
0
def test_man_completion(monkeypatch, tmpdir, xonsh_builtins):
    tempdir = tmpdir.mkdir('test_man')
    monkeypatch.setitem(os.environ, 'MANPATH', os.path.dirname(os.path.abspath(__file__)))
    xonsh_builtins.__xonsh_env__.update({'XONSH_DATA_DIR': str(tempdir)})
    completions = complete_from_man('--', 'yes --', 4, 6,
                                    xonsh_builtins.__xonsh_env__)
    assert '--version' in completions
    assert '--help' in completions
Esempio n. 4
0
def complete_rmdir(command: CommandContext):
    """
    Completion for "rmdir", includes only valid directory names.
    """
    opts = complete_from_man(CompletionContext(command))
    comps, lp = complete_dir(command)
    if len(comps) == 0 and len(opts) == 0:
        raise StopIteration
    return comps | opts, lp
Esempio n. 5
0
def complete_rmdir(prefix, line, start, end, ctx):
    """
    Completion for "rmdir", includes only valid directory names.
    """
    if start != 0 and line.split(" ")[0] == "rmdir":
        opts = {i for i in complete_from_man("-", "rmdir -", 6, 7, ctx) if i.startswith(prefix)}
        comps, lp = complete_dir(prefix, line, start, end, ctx, True)
        return comps | opts, lp
    return set()
Esempio n. 6
0
def test_man_completion(monkeypatch, tmpdir, xonsh_builtins):
    tempdir = tmpdir.mkdir("test_man")
    monkeypatch.setitem(
        os.environ, "MANPATH", os.path.dirname(os.path.abspath(__file__))
    )
    xonsh_builtins.__xonsh__.env.update({"XONSH_DATA_DIR": str(tempdir)})
    completions = complete_from_man("--", "yes --", 4, 6, xonsh_builtins.__xonsh__.env)
    assert "--version" in completions
    assert "--help" in completions
Esempio n. 7
0
def test_man_completion(monkeypatch, tmpdir, xonsh_builtins):
    tempdir = tmpdir.mkdir("test_man")
    monkeypatch.setitem(os.environ, "MANPATH",
                        os.path.dirname(os.path.abspath(__file__)))
    xonsh_builtins.__xonsh__.env.update({"XONSH_DATA_DIR": str(tempdir)})
    completions = complete_from_man("--", "yes --", 4, 6,
                                    xonsh_builtins.__xonsh__.env)
    assert "--version" in completions
    assert "--help" in completions
Esempio n. 8
0
def complete_rmdir(prefix, line, start, end, ctx):
    """
    Completion for "rmdir", includes only valid directory names.
    """
    if start != 0 and line.split(' ')[0] == 'rmdir':
        opts = {i for i in complete_from_man('-', 'rmdir -', 6, 7, ctx)
                if i.startswith(prefix)}
        comps, lp = complete_dir(prefix, line, start, end, ctx, True)
        return comps | opts, lp
    return set()
Esempio n. 9
0
def test_man_completion(monkeypatch, tmpdir, xonsh_builtins):
    tempdir = tmpdir.mkdir("test_man")
    monkeypatch.setitem(
        os.environ, "MANPATH", os.path.dirname(os.path.abspath(__file__))
    )
    xonsh_builtins.__xonsh__.env.update({"XONSH_DATA_DIR": str(tempdir)})
    completions = complete_from_man(CompletionContext(
        CommandContext(args=(CommandArg("yes"),), arg_index=1, prefix="--")
    ))
    assert "--version" in completions
    assert "--help" in completions
Esempio n. 10
0
def complete_rmdir(prefix, line, start, end, ctx):
    """
    Completion for "rmdir", includes only valid directory names.
    """
    if start != 0 and line.split(" ")[0] == "rmdir":
        opts = {
            i
            for i in complete_from_man("-", "rmdir -", 6, 7, ctx)
            if i.startswith(prefix)
        }
        comps, lp = complete_dir(prefix, line, start, end, ctx, True)
        if len(comps) == 0 and len(opts) == 0:
            raise StopIteration
        return comps | opts, lp
    return set()