• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TTRPG-Dev / ex_ttrpg_dev / e536cc6c705aa7f7db21425e4d713c2bff72f814-PR-50

01 Mar 2026 01:40AM UTC coverage: 85.399%. Remained the same
e536cc6c705aa7f7db21425e4d713c2bff72f814-PR-50

Pull #50

github

QMalcolm
Add exit() as an alias for the exit command in the shell
Pull Request #50: Alias exit() to exit in the shell

0 of 1 new or added line in 1 file covered. (0.0%)

310 of 363 relevant lines covered (85.4%)

141.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/apps/ttrpg_dev_cli/lib/cli/shell.ex
1
defmodule ExTTRPGDev.CLI.Shell do
2
  @moduledoc """
3
  Interactive REPL shell for ttrpg-dev.
4
  Launched when the binary is invoked with no arguments.
5
  """
6

7
  @prompt "ttrpg-dev> "
8

9
  defmodule HaltSignal do
10
    defexception [:code, message: "halt requested in shell mode"]
11
  end
12

13
  def run(optimus) do
14
    IO.puts(banner())
×
15
    loop(optimus)
×
16
  end
17

18
  defp loop(optimus) do
19
    case IO.gets(@prompt) do
×
20
      :eof ->
21
        IO.puts("\nGoodbye!")
×
22

23
      {:error, reason} ->
24
        IO.puts("Input error: #{inspect(reason)}")
×
25

26
      line when is_binary(line) ->
27
        case line |> String.trim() |> handle_input(optimus) do
×
28
          :exit -> IO.puts("Goodbye!")
×
29
          :continue -> loop(optimus)
×
30
        end
31
    end
32
  end
33

34
  defp handle_input("", _optimus), do: :continue
×
35

NEW
36
  defp handle_input(cmd, _optimus) when cmd in ["exit", "quit", "exit()"], do: :exit
×
37

38
  defp handle_input("help", _optimus) do
39
    IO.puts("""
×
40
    Commands (same syntax as the CLI):
41
      roll <dice>                                Roll dice, e.g. roll 3d6
42
      systems list                               List configured rule systems
43
      systems show <cmd>                         Show system info (abilities/languages/metadata/skills)
44
      characters gen <system>                    Generate a character
45
      characters list                            List saved characters
46
      characters show <slug>                     Show a saved character
47
      help                                       Show this help
48
      exit / quit                                Exit the shell
49
    """)
50

51
    :continue
52
  end
53

54
  defp handle_input(input, optimus) do
55
    tokens = OptionParser.split(input)
×
56

57
    try do
×
58
      ExTTRPGDev.CLI.dispatch(tokens, optimus, &shell_halt/1)
×
59
    rescue
60
      e in HaltSignal ->
×
61
        if e.code != 0, do: IO.puts("(Use `help` to see available commands)")
×
62

63
      e ->
×
64
        IO.puts("Error: #{Exception.message(e)}")
×
65
    end
66

67
    :continue
68
  end
69

70
  defp shell_halt(code), do: raise(HaltSignal, code: code)
×
71

72
  defp banner do
×
73
    """
74
    TTRPG Dev — interactive shell
75
    Type `help` for available commands, `exit` to quit.
76
    """
77
  end
78
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc