langstage-cli 0.6.60__tar.gz → 0.6.61__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {langstage_cli-0.6.60/langstage_cli.egg-info → langstage_cli-0.6.61}/PKG-INFO +1 -1
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli/cli.py +24 -7
- {langstage_cli-0.6.60 → langstage_cli-0.6.61/langstage_cli.egg-info}/PKG-INFO +1 -1
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli.egg-info/SOURCES.txt +1 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/pyproject.toml +1 -1
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_dumb_term.py +3 -1
- langstage_cli-0.6.61/tests/test_mintty_approval_219.py +145 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/LICENSE +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/README.md +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/deepagent_code/__init__.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli/__init__.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli/agui_stream.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli/config.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli/exit_codes.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli/sessions.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli.egg-info/dependency_links.txt +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli.egg-info/entry_points.txt +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli.egg-info/requires.txt +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/langstage_cli.egg-info/top_level.txt +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/setup.cfg +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_advertised_wave4.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_agui_stream.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_approval_menu_abort.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_approval_menu_keys_211.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_async_mode.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_checkpointer.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_cli.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_cli_help.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_codeconfig.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_config.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_config_command.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_configurable.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_ctrl_c_sync_tool.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_custom_decision_195.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_decision_shapes_209.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_deferred_pass.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_exit_codes.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_generic_interrupt.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_help_render.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_hidden_option_suggestions.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_history_persist.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_hitl_approval_preview.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_hitl_resume_warning.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_init.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_interrupt_answer_text_206.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_interrupt_non_tty.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_legacy_config_home.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_load_error.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_menu_allowed_197.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_message_boundaries.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_no_color.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_no_interactive_approve.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_no_persist_resume.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_nul_approval_217.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_paused_session_message.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_persist_env.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_quiet_output.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_quiet_tool_result_204.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_reasoning_render.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_rename_shim.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_render_markdown.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_routine_1024.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_session_agent_215.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_session_lifecycle.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_sessions.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_show_config.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_show_config_bare_spec_213.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_show_config_malformed.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_spec_loading_core.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_spec_resolution.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_spinner_reply_survives.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_stdin_interactive.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_stdin_single_shot.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_stream_mode.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_streaming_marker.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_terminal_width.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_toml_relative_paths.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_tool_card_args.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_tool_output_escape.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_turn_error_verbose.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_turn_exit_and_render.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_unicode_console.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_usage_hint_186.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_verbose_command.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_verify_flag.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_workspace.py +0 -0
- {langstage_cli-0.6.60 → langstage_cli-0.6.61}/tests/test_wrong_type_graph.py +0 -0
|
@@ -1890,12 +1890,18 @@ def select_option(options: List[str], prompt: str = "Select an option:") -> int:
|
|
|
1890
1890
|
|
|
1891
1891
|
|
|
1892
1892
|
def _select_option_typed(options: List[str], prompt: str) -> int:
|
|
1893
|
-
"""The approval menu
|
|
1893
|
+
"""The approval menu as a numbered list and a typed choice.
|
|
1894
1894
|
|
|
1895
1895
|
The arrow-key menu redraws itself with cursor-up and line-clear escapes, which a
|
|
1896
1896
|
dumb terminal prints as literal text, and editor shells (Emacs ``M-x shell``) send
|
|
1897
|
-
whole lines, not keypresses.
|
|
1898
|
-
|
|
1897
|
+
whole lines, not keypresses (gh #182). A mintty / Git Bash pty on Windows feeds
|
|
1898
|
+
lines to stdin but not the keypresses ``msvcrt.getch()`` reads, so it gets this
|
|
1899
|
+
menu too (gh #219).
|
|
1900
|
+
|
|
1901
|
+
A choice is the option's number, or a word that starts exactly one option's label
|
|
1902
|
+
(``a`` or ``approve`` for "Approve all actions", ``r``, ``e`` ...). Enter alone
|
|
1903
|
+
picks the first option. ``q``, Ctrl-C or end of input abandon the prompt the same
|
|
1904
|
+
way the arrow-key menu's Esc does: exit 2, paused.
|
|
1899
1905
|
"""
|
|
1900
1906
|
print(f"\n{prompt}")
|
|
1901
1907
|
for i, opt in enumerate(options, 1):
|
|
@@ -1910,7 +1916,14 @@ def _select_option_typed(options: List[str], prompt: str) -> int:
|
|
|
1910
1916
|
return 0
|
|
1911
1917
|
if raw.isdigit() and 1 <= int(raw) <= len(options):
|
|
1912
1918
|
return int(raw) - 1
|
|
1913
|
-
|
|
1919
|
+
word = raw.lower()
|
|
1920
|
+
if word in ("q", "quit"):
|
|
1921
|
+
print()
|
|
1922
|
+
sys.exit(EXIT_PAUSED)
|
|
1923
|
+
matches = [i for i, opt in enumerate(options) if opt.lower().startswith(word)]
|
|
1924
|
+
if len(matches) == 1:
|
|
1925
|
+
return matches[0]
|
|
1926
|
+
print(f"Enter a number from 1 to {len(options)}, or the start of an option's name.")
|
|
1914
1927
|
|
|
1915
1928
|
|
|
1916
1929
|
def _prompt_line(prompt: str) -> str:
|
|
@@ -1965,7 +1978,10 @@ def handle_interrupt_input(
|
|
|
1965
1978
|
# stopping. `--no-interactive` remains the documented way to opt into
|
|
1966
1979
|
# auto-approval, and the message points at it. (gh #86) On Windows `<NUL` passes
|
|
1967
1980
|
# isatty() but can't feed the menu's msvcrt.getch(), so it's checked too (gh #217).
|
|
1968
|
-
|
|
1981
|
+
# A mintty / Git Bash pty is a person at a terminal whose keypresses getch() can't
|
|
1982
|
+
# read either, but it does feed lines, so it gets the typed menu (gh #219).
|
|
1983
|
+
typed = not _stdin_drives_menu() and _stdin_is_interactive()
|
|
1984
|
+
if not typed and not _stdin_drives_menu():
|
|
1969
1985
|
print(
|
|
1970
1986
|
"Error: approval required but stdin is not a terminal.\n"
|
|
1971
1987
|
"Re-run with --no-interactive to auto-approve pending actions.",
|
|
@@ -1973,6 +1989,7 @@ def handle_interrupt_input(
|
|
|
1973
1989
|
)
|
|
1974
1990
|
# The run is fine but paused on human input: the family "paused" code (ADR 0007).
|
|
1975
1991
|
sys.exit(EXIT_PAUSED)
|
|
1992
|
+
pick = _select_option_typed if typed else select_option
|
|
1976
1993
|
|
|
1977
1994
|
if is_generic:
|
|
1978
1995
|
# A generic interrupt() asks for an arbitrary value, not tool approval, so
|
|
@@ -1982,7 +1999,7 @@ def handle_interrupt_input(
|
|
|
1982
1999
|
# case, where the user types `Alice` and the agent must receive `"Alice"`,
|
|
1983
2000
|
# not an envelope. What was typed is the answer, as text (gh #206).
|
|
1984
2001
|
options = ["Provide a response", "Exit"]
|
|
1985
|
-
choice =
|
|
2002
|
+
choice = pick(options, "How would you like to respond?")
|
|
1986
2003
|
if choice != 0:
|
|
1987
2004
|
sys.exit(EXIT_PAUSED) # left while paused on the interrupt (ADR 0007)
|
|
1988
2005
|
print(
|
|
@@ -2003,7 +2020,7 @@ def handle_interrupt_input(
|
|
|
2003
2020
|
options = [label for label, _ in entries]
|
|
2004
2021
|
|
|
2005
2022
|
while True:
|
|
2006
|
-
action = entries[
|
|
2023
|
+
action = entries[pick(options, "How would you like to proceed?")][1]
|
|
2007
2024
|
|
|
2008
2025
|
if action in ("approve", "reject"):
|
|
2009
2026
|
return {"decisions": [{"type": action} for _ in range(num_actions)]}
|
|
@@ -45,6 +45,7 @@ tests/test_legacy_config_home.py
|
|
|
45
45
|
tests/test_load_error.py
|
|
46
46
|
tests/test_menu_allowed_197.py
|
|
47
47
|
tests/test_message_boundaries.py
|
|
48
|
+
tests/test_mintty_approval_219.py
|
|
48
49
|
tests/test_no_color.py
|
|
49
50
|
tests/test_no_interactive_approve.py
|
|
50
51
|
tests/test_no_persist_resume.py
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "langstage-cli"
|
|
7
|
-
version = "0.6.
|
|
7
|
+
version = "0.6.61"
|
|
8
8
|
description = "The terminal stage for your LangGraph agent — Claude Code-style CLI for any CompiledGraph"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -96,7 +96,9 @@ def test_menu_asks_again_on_a_bad_choice(dumb, monkeypatch):
|
|
|
96
96
|
with redirect_stdout(buf):
|
|
97
97
|
assert cli.select_option(["Approve", "Reject"]) == 1
|
|
98
98
|
assert len(prompts) == 3
|
|
99
|
-
assert
|
|
99
|
+
assert (
|
|
100
|
+
buf.getvalue().count("Enter a number from 1 to 2, or the start of an option's name.") == 2
|
|
101
|
+
)
|
|
100
102
|
|
|
101
103
|
|
|
102
104
|
@pytest.mark.parametrize("abort", [KeyboardInterrupt(), EOFError()], ids=["ctrl-c", "eof"])
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""Approvals can be answered in a mintty / Git Bash terminal (gh #219).
|
|
2
|
+
|
|
3
|
+
On Windows a mintty pty is a pipe with an MSYS pty name. It counts as interactive, so
|
|
4
|
+
the REPL runs, but the arrow-key approval menu reads keys with ``msvcrt.getch()``,
|
|
5
|
+
which can't read it. Since gh #217 the first approval therefore exited 2. The menu now
|
|
6
|
+
falls back to the typed, line-based menu there: a number, or a word that starts one
|
|
7
|
+
option's name. ``NUL`` and real pipes still exit 2.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import builtins
|
|
11
|
+
|
|
12
|
+
import pytest
|
|
13
|
+
|
|
14
|
+
from langstage_cli import cli
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _mintty(monkeypatch):
|
|
18
|
+
monkeypatch.setattr(cli, "_stdin_drives_menu", lambda stream=None: False)
|
|
19
|
+
monkeypatch.setattr(cli, "_stdin_is_interactive", lambda stream=None: True)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _feed(monkeypatch, *lines):
|
|
23
|
+
it = iter(lines)
|
|
24
|
+
|
|
25
|
+
def fake_input(prompt=""):
|
|
26
|
+
try:
|
|
27
|
+
return next(it)
|
|
28
|
+
except StopIteration:
|
|
29
|
+
raise EOFError from None
|
|
30
|
+
|
|
31
|
+
monkeypatch.setattr(builtins, "input", fake_input)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _no_keys(monkeypatch):
|
|
35
|
+
def boom():
|
|
36
|
+
raise AssertionError("the arrow-key menu must not read keys here")
|
|
37
|
+
|
|
38
|
+
monkeypatch.setattr(cli, "get_key", boom)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@pytest.mark.parametrize(
|
|
42
|
+
"answer, verb",
|
|
43
|
+
[
|
|
44
|
+
("1", "approve"),
|
|
45
|
+
("2", "reject"),
|
|
46
|
+
("a", "approve"),
|
|
47
|
+
("approve", "approve"),
|
|
48
|
+
("R", "reject"),
|
|
49
|
+
("Reject", "reject"),
|
|
50
|
+
("", "approve"),
|
|
51
|
+
],
|
|
52
|
+
)
|
|
53
|
+
def test_mintty_answers_the_approval_with_a_typed_line(monkeypatch, capsys, answer, verb):
|
|
54
|
+
_mintty(monkeypatch)
|
|
55
|
+
_no_keys(monkeypatch)
|
|
56
|
+
_feed(monkeypatch, answer)
|
|
57
|
+
result = cli.handle_interrupt_input(num_actions=2)
|
|
58
|
+
assert result == {"decisions": [{"type": verb}, {"type": verb}]}
|
|
59
|
+
out = capsys.readouterr().out
|
|
60
|
+
assert "1. Approve all actions" in out
|
|
61
|
+
assert "\033[?25l" not in out # no cursor escapes from the arrow-key menu
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@pytest.mark.parametrize("answer", ["4", "e", "exit", "q", "quit"])
|
|
65
|
+
def test_mintty_leaving_the_menu_exits_paused(monkeypatch, answer):
|
|
66
|
+
_mintty(monkeypatch)
|
|
67
|
+
_no_keys(monkeypatch)
|
|
68
|
+
_feed(monkeypatch, answer)
|
|
69
|
+
with pytest.raises(SystemExit) as exc:
|
|
70
|
+
cli.handle_interrupt_input(num_actions=1)
|
|
71
|
+
assert exc.value.code == cli.EXIT_PAUSED
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_mintty_end_of_input_exits_paused(monkeypatch):
|
|
75
|
+
_mintty(monkeypatch)
|
|
76
|
+
_no_keys(monkeypatch)
|
|
77
|
+
_feed(monkeypatch) # EOF at once
|
|
78
|
+
with pytest.raises(SystemExit) as exc:
|
|
79
|
+
cli.handle_interrupt_input(num_actions=1)
|
|
80
|
+
assert exc.value.code == cli.EXIT_PAUSED
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_mintty_unknown_answer_asks_again(monkeypatch, capsys):
|
|
84
|
+
_mintty(monkeypatch)
|
|
85
|
+
_no_keys(monkeypatch)
|
|
86
|
+
_feed(monkeypatch, "maybe", "9", "a")
|
|
87
|
+
assert cli.handle_interrupt_input(num_actions=1) == {"decisions": [{"type": "approve"}]}
|
|
88
|
+
out = capsys.readouterr().out
|
|
89
|
+
assert out.count("or the start of an option's name") == 2
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_mintty_generic_interrupt_takes_a_typed_answer(monkeypatch):
|
|
93
|
+
_mintty(monkeypatch)
|
|
94
|
+
_no_keys(monkeypatch)
|
|
95
|
+
_feed(monkeypatch, "p", "Alice")
|
|
96
|
+
assert cli.handle_interrupt_input(is_generic=True) == "Alice"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_mintty_custom_decision_flow(monkeypatch):
|
|
100
|
+
_mintty(monkeypatch)
|
|
101
|
+
_no_keys(monkeypatch)
|
|
102
|
+
_feed(monkeypatch, "3", '[{"type": "reject", "message": "not now"}]')
|
|
103
|
+
assert cli.handle_interrupt_input(num_actions=1) == {
|
|
104
|
+
"decisions": [{"type": "reject", "message": "not now"}]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_mintty_honours_allowed_decisions(monkeypatch, capsys):
|
|
109
|
+
# An approve-only action offers no "Reject all", so "r" matches nothing.
|
|
110
|
+
_mintty(monkeypatch)
|
|
111
|
+
_no_keys(monkeypatch)
|
|
112
|
+
_feed(monkeypatch, "r", "a")
|
|
113
|
+
interrupt = {
|
|
114
|
+
"action_requests": [{"name": "send_email", "args": {}}],
|
|
115
|
+
"review_configs": [{"action_name": "send_email", "allowed_decisions": ["approve"]}],
|
|
116
|
+
}
|
|
117
|
+
assert cli.handle_interrupt_input(num_actions=1, interrupt=interrupt) == {
|
|
118
|
+
"decisions": [{"type": "approve"}]
|
|
119
|
+
}
|
|
120
|
+
assert "Reject all actions" not in capsys.readouterr().out
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def test_ambiguous_prefix_asks_again(monkeypatch):
|
|
124
|
+
_feed(monkeypatch, "rej", "2")
|
|
125
|
+
assert cli._select_option_typed(["Reject all", "Reject one"], "Pick") == 1
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def test_not_interactive_still_exits_paused(monkeypatch, capsys):
|
|
129
|
+
# NUL or a real pipe: neither drives the menu nor counts as a person (gh #217).
|
|
130
|
+
monkeypatch.setattr(cli, "_stdin_drives_menu", lambda stream=None: False)
|
|
131
|
+
monkeypatch.setattr(cli, "_stdin_is_interactive", lambda stream=None: False)
|
|
132
|
+
_no_keys(monkeypatch)
|
|
133
|
+
with pytest.raises(SystemExit) as exc:
|
|
134
|
+
cli.handle_interrupt_input(num_actions=1)
|
|
135
|
+
assert exc.value.code == cli.EXIT_PAUSED
|
|
136
|
+
assert "approval required but stdin is not a terminal" in capsys.readouterr().err
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def test_real_console_keeps_the_arrow_menu(monkeypatch, capsys):
|
|
140
|
+
monkeypatch.setattr(cli, "_stdin_drives_menu", lambda stream=None: True)
|
|
141
|
+
monkeypatch.setattr(cli, "_stdin_is_interactive", lambda stream=None: True)
|
|
142
|
+
monkeypatch.setattr(cli, "_DUMB_TERM", False)
|
|
143
|
+
monkeypatch.setattr(cli, "get_key", lambda: "enter")
|
|
144
|
+
assert cli.handle_interrupt_input(num_actions=1) == {"decisions": [{"type": "approve"}]}
|
|
145
|
+
assert "Choose 1-" not in capsys.readouterr().out
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|