mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 23:47:54 +08:00
cli/display: label regex_files lines with Search
This commit is contained in:
@@ -335,7 +335,7 @@ def _glob_detail(_args_json: str, result: str) -> str:
|
|||||||
def _regex_prefix(args_json: str) -> str:
|
def _regex_prefix(args_json: str) -> str:
|
||||||
pattern = _json_str_arg(args_json, "pattern") or "?"
|
pattern = _json_str_arg(args_json, "pattern") or "?"
|
||||||
path = _json_str_arg(args_json, "path") or "."
|
path = _json_str_arg(args_json, "path") or "."
|
||||||
return _pretty_prefix(f"* Grep '{pattern}' in '{path}' ")
|
return _pretty_prefix(f"* Search '{pattern}' in '{path}' ")
|
||||||
|
|
||||||
|
|
||||||
def _regex_detail(_args_json: str, result: str) -> str:
|
def _regex_detail(_args_json: str, result: str) -> str:
|
||||||
|
|||||||
@@ -350,17 +350,17 @@ async def test_pretty_glob_truncated(capsys: pytest.CaptureFixture[str]) -> None
|
|||||||
assert "* Glob '*' in '.' (2 paths)" in out
|
assert "* Glob '*' in '.' (2 paths)" in out
|
||||||
|
|
||||||
|
|
||||||
async def test_pretty_grep(capsys: pytest.CaptureFixture[str]) -> None:
|
async def test_pretty_regex_files(capsys: pytest.CaptureFixture[str]) -> None:
|
||||||
result = "src/a.py:3: x = 1\nsrc/a.py:9: x = 2\nsrc/b.py:1: y = 3\n"
|
result = "src/a.py:3: x = 1\nsrc/a.py:9: x = 2\nsrc/b.py:1: y = 3\n"
|
||||||
await render_events(_aiter([_pretty_call("regex_files", '{"pattern": "x"}'), _result(result)]))
|
await render_events(_aiter([_pretty_call("regex_files", '{"pattern": "x"}'), _result(result)]))
|
||||||
out = capsys.readouterr().out
|
out = capsys.readouterr().out
|
||||||
assert "* Grep 'x' in '.' (3 matches in 2 files)" in out
|
assert "* Search 'x' in '.' (3 matches in 2 files)" in out
|
||||||
|
|
||||||
|
|
||||||
async def test_pretty_grep_no_matches(capsys: pytest.CaptureFixture[str]) -> None:
|
async def test_pretty_regex_files_no_matches(capsys: pytest.CaptureFixture[str]) -> None:
|
||||||
await render_events(_aiter([_pretty_call("regex_files", '{"pattern": "zzz"}'), _result("(no matches)")]))
|
await render_events(_aiter([_pretty_call("regex_files", '{"pattern": "zzz"}'), _result("(no matches)")]))
|
||||||
out = capsys.readouterr().out
|
out = capsys.readouterr().out
|
||||||
assert "* Grep 'zzz' in '.' (no matches)" in out
|
assert "* Search 'zzz' in '.' (no matches)" in out
|
||||||
|
|
||||||
|
|
||||||
async def test_pretty_run_argv_success(capsys: pytest.CaptureFixture[str]) -> None:
|
async def test_pretty_run_argv_success(capsys: pytest.CaptureFixture[str]) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user