myshell-py 0.3.2__tar.gz → 0.3.5__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.
- {myshell_py-0.3.2 → myshell_py-0.3.5}/PKG-INFO +1 -1
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/guide.py +28 -5
- {myshell_py-0.3.2 → myshell_py-0.3.5}/pyproject.toml +1 -1
- {myshell_py-0.3.2 → myshell_py-0.3.5}/.gitignore +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/README.md +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/__init__.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/__main__.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/aliases.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/arith.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/builtins.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/cli.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/compat.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/completion.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/coreutils.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/editor.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/errors.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/executor.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/expand.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/heredoc.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/highlight.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/history.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/jobs.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/lexer.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/more_builtins.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/parser.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/paths.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/progress.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/prompt.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/quiz.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/state.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/theme.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/pytest.ini +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/requirements.txt +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/shell.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/src/myshell/__init__.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/conftest.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_aliases.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_arith.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_builtins.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_cli.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_completion.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_coreutils.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_editor.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_expand.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_expansion_e2e.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_guide.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_heredoc.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_highlight.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_history.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_history_fallback.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_if.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_interactive.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_jobs.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_language.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_lexer.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_loops.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_more_builtins.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_parser.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_pipelines.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_prompt.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_quiz_progress.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_redirects.py +0 -0
- {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_theme.py +0 -0
|
@@ -23,6 +23,7 @@ from pathlib import Path
|
|
|
23
23
|
from typing import Callable, List, Optional, TextIO
|
|
24
24
|
|
|
25
25
|
from . import compat, history, progress, quiz, theme
|
|
26
|
+
from .errors import ShellError
|
|
26
27
|
from .state import ShellState
|
|
27
28
|
|
|
28
29
|
# --- the character ---------------------------------------------------------
|
|
@@ -401,6 +402,25 @@ def make_ask() -> Ask:
|
|
|
401
402
|
return ask
|
|
402
403
|
|
|
403
404
|
|
|
405
|
+
def run_checked(state: ShellState, line: str, out: TextIO) -> None:
|
|
406
|
+
"""Run a lesson line. Pip explains syntax errors and unknown commands."""
|
|
407
|
+
state.missing_command = None
|
|
408
|
+
try:
|
|
409
|
+
state.execute(line)
|
|
410
|
+
except ShellError as e:
|
|
411
|
+
print(e, file=sys.stderr)
|
|
412
|
+
state.last_status = 2
|
|
413
|
+
hint = syntax_hint(str(e))
|
|
414
|
+
say(hint or "That line has a syntax error. Check quotes, brackets, then and fi.",
|
|
415
|
+
"worried", out)
|
|
416
|
+
except Exception as e: # a lesson must never close the shell
|
|
417
|
+
print(e, file=out)
|
|
418
|
+
if state.missing_command:
|
|
419
|
+
hint = missing_hint(state.missing_command, state)
|
|
420
|
+
if hint:
|
|
421
|
+
say(hint, "worried", out)
|
|
422
|
+
|
|
423
|
+
|
|
404
424
|
def run_lesson(state: ShellState, lesson: Lesson, out: TextIO, ask: Ask) -> bool:
|
|
405
425
|
"""Teach one lesson. Returns False when the person stops or input ends."""
|
|
406
426
|
say(f"{lesson.title}: {lesson.summary}.", "happy", out)
|
|
@@ -420,10 +440,13 @@ def run_lesson(state: ShellState, lesson: Lesson, out: TextIO, ask: Ask) -> bool
|
|
|
420
440
|
if answer.lower() == "s":
|
|
421
441
|
continue
|
|
422
442
|
saved = state.last_status
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
443
|
+
typed = answer.strip()
|
|
444
|
+
line = typed if typed and typed.lower() not in ("y", "yes") else step.command
|
|
445
|
+
if line != step.command:
|
|
446
|
+
say("You typed your own version. I will run it and check it.", "think", out)
|
|
447
|
+
run_checked(state, line, out)
|
|
448
|
+
if line != step.command and state.last_status == 0:
|
|
449
|
+
say(f"It ran. The lesson used: {step.command.splitlines()[0]}", "happy", out)
|
|
427
450
|
state.last_status = saved
|
|
428
451
|
print(file=out)
|
|
429
452
|
progress.mark_lesson(state.progress_file, lesson.key)
|
|
@@ -614,4 +637,4 @@ def guide_main(state: ShellState, args: List[str], stdout: TextIO, stderr: TextI
|
|
|
614
637
|
file=stderr)
|
|
615
638
|
return 1
|
|
616
639
|
run_lesson(state, lesson, stdout, make_ask())
|
|
617
|
-
return 0
|
|
640
|
+
return 0
|
|
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
|