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.
Files changed (63) hide show
  1. {myshell_py-0.3.2 → myshell_py-0.3.5}/PKG-INFO +1 -1
  2. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/guide.py +28 -5
  3. {myshell_py-0.3.2 → myshell_py-0.3.5}/pyproject.toml +1 -1
  4. {myshell_py-0.3.2 → myshell_py-0.3.5}/.gitignore +0 -0
  5. {myshell_py-0.3.2 → myshell_py-0.3.5}/README.md +0 -0
  6. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/__init__.py +0 -0
  7. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/__main__.py +0 -0
  8. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/aliases.py +0 -0
  9. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/arith.py +0 -0
  10. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/builtins.py +0 -0
  11. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/cli.py +0 -0
  12. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/compat.py +0 -0
  13. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/completion.py +0 -0
  14. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/coreutils.py +0 -0
  15. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/editor.py +0 -0
  16. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/errors.py +0 -0
  17. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/executor.py +0 -0
  18. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/expand.py +0 -0
  19. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/heredoc.py +0 -0
  20. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/highlight.py +0 -0
  21. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/history.py +0 -0
  22. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/jobs.py +0 -0
  23. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/lexer.py +0 -0
  24. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/more_builtins.py +0 -0
  25. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/parser.py +0 -0
  26. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/paths.py +0 -0
  27. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/progress.py +0 -0
  28. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/prompt.py +0 -0
  29. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/quiz.py +0 -0
  30. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/state.py +0 -0
  31. {myshell_py-0.3.2 → myshell_py-0.3.5}/myshell/theme.py +0 -0
  32. {myshell_py-0.3.2 → myshell_py-0.3.5}/pytest.ini +0 -0
  33. {myshell_py-0.3.2 → myshell_py-0.3.5}/requirements.txt +0 -0
  34. {myshell_py-0.3.2 → myshell_py-0.3.5}/shell.py +0 -0
  35. {myshell_py-0.3.2 → myshell_py-0.3.5}/src/myshell/__init__.py +0 -0
  36. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/conftest.py +0 -0
  37. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_aliases.py +0 -0
  38. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_arith.py +0 -0
  39. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_builtins.py +0 -0
  40. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_cli.py +0 -0
  41. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_completion.py +0 -0
  42. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_coreutils.py +0 -0
  43. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_editor.py +0 -0
  44. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_expand.py +0 -0
  45. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_expansion_e2e.py +0 -0
  46. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_guide.py +0 -0
  47. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_heredoc.py +0 -0
  48. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_highlight.py +0 -0
  49. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_history.py +0 -0
  50. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_history_fallback.py +0 -0
  51. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_if.py +0 -0
  52. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_interactive.py +0 -0
  53. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_jobs.py +0 -0
  54. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_language.py +0 -0
  55. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_lexer.py +0 -0
  56. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_loops.py +0 -0
  57. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_more_builtins.py +0 -0
  58. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_parser.py +0 -0
  59. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_pipelines.py +0 -0
  60. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_prompt.py +0 -0
  61. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_quiz_progress.py +0 -0
  62. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_redirects.py +0 -0
  63. {myshell_py-0.3.2 → myshell_py-0.3.5}/tests/test_theme.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: myshell-py
3
- Version: 0.3.2
3
+ Version: 0.3.5
4
4
  Summary: A Unix-style shell written in Python, with a built-in guide.
5
5
  License: MIT
6
6
  Keywords: education,shell,terminal
@@ -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
- try:
424
- state.execute(step.command)
425
- except Exception as e: # a lesson must never close the shell
426
- print(e, file=out)
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
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "myshell-py"
7
- version = "0.3.2"
7
+ version = "0.3.5"
8
8
  description = "A Unix-style shell written in Python, with a built-in guide."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
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