Module: Lich::Main::HelpText

Defined in:
documented/main/help_text.rb

Overview

Renders user-facing CLI help text by topic.

Constant Summary collapse

HELP_TOPICS =

Valid help topic names.

See Also:

%w[login accounts automation paths advanced].freeze

Class Method Summary collapse

Class Method Details

.accounts_helpString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Renders help text for the accounts topic, including password and encryption management.

Returns:

  • (String)

    formatted help output



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'documented/main/help_text.rb', line 155

def self.accounts_help
  <<~TEXT
    Lich Help: accounts

    Usage:
      lich [account command] [options]

    Commands:
      --add-account ACCOUNT PASSWORD
      --change-account-password ACCOUNT NEWPASSWORD
      --change-master-password OLDPASSWORD [NEWPASSWORD]
      --recover-master-password [NEWPASSWORD]
      --convert-entries MODE
      --change-encryption-mode MODE [--master-password PASSWORD]

    Modes:
      plaintext
      standard
      enhanced

    Examples:
      lich --add-account MYACCOUNT MYPASSWORD --frontend stormfront
      lich --change-account-password MYACCOUNT NEWPASSWORD
      lich --convert-entries enhanced
      lich --change-encryption-mode enhanced --master-password SECRET
  TEXT
end

.advanced_helpString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Renders help text for the advanced topic, including GUI, networking, and compatibility options.

Returns:

  • (String)

    formatted help output



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'documented/main/help_text.rb', line 237

def self.advanced_help
  <<~TEXT
    Lich Help: advanced

    Compatibility / advanced options:
      --gui
      --no-gui, --no-gtk  Run without the GTK GUI (aliases)
      --without-frontend
      --detachable-client=PORT|auto|HOST:PORT
      --pipe
      --frontend=NAME
      --frontend-command=CMD
      --game=HOST:PORT
      --bind-address=HOST

    Notes:
      The GTK GUI starts by default. To suppress it, pass --no-gui or --no-gtk,
      including when using --headless.
      Prefer --headless PORT or --headless auto for new headless launches.
      --pipe uses stdin/stdout as the client transport instead of a front-end socket.
      --bind-address=HOST sets the local address Lich binds its listen sockets to
      (the frontend, --game proxy, and detachable-client listeners).
      Defaults to 127.0.0.1.
      HOST -- in --bind-address, --headless, and --detachable-client alike -- may
      be an IP, a hostname, a keyword, or (with a port) a bracketed IPv6 literal
      such as [::1]:PORT. Keywords: tailscale (this machine's Tailscale address),
      lan (its private LAN address), or any (0.0.0.0). Lich's listen sockets are
      unauthenticated - anyone who can reach one controls the session - so
      prefer tailscale over lan or any.
      Multiple frontends may attach to one detachable port. Each receives game
      output, and commands from all attached frontends are processed serially.
      Compatibility flags remain supported but are intentionally omitted from the default help screen.
  TEXT
end

.automation_helpString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Renders help text for the automation topic, including session inspection commands.

Returns:

  • (String)

    formatted help output



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'documented/main/help_text.rb', line 187

def self.automation_help
  <<~TEXT
    Lich Help: automation

    Usage:
      lich [automation command]

    Commands:
      --active-sessions       List live sessions
      --session-info NAME     Show live session details for NAME

    Examples:
      lich --active-sessions
      lich --session-info Mychar
  TEXT
end

.default_helpString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Renders the default help text with common commands and available topics.

Returns:

  • (String)

    formatted help output



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'documented/main/help_text.rb', line 70

def self.default_help
  <<~TEXT
    Lich 5
    Usage:
      lich [command] [options]

    Most common:
      lich --login CHARACTER
      lich --login CHARACTER --headless PORT
      lich --login CHARACTER --headless auto
      lich --add-account ACCOUNT PASSWORD

    Help topics:
      lich --help login
      lich --help accounts
      lich --help automation
      lich --help paths
      lich --help advanced

    General:
      --help                  Show help
      --version               Show version
  TEXT
end

.login_helpString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Renders help text for the login topic, including game/frontend/launch options.

Returns:

  • (String)

    formatted help output



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'documented/main/help_text.rb', line 99

def self.
  <<~TEXT
    Lich Help: login

    Usage:
      lich --login CHARACTER [options]

    Login options:
      --login CHARACTER       Login using a saved entry
      --headless PORT         Run without a frontend and expose a detachable client on PORT
      --headless auto         Run without a frontend and let the OS assign a detachable port
      --headless HOST:PORT    Bind the detachable client to HOST (tailscale, lan, any, IP, or hostname)
      --start-scripts=LIST    Start scripts after login (comma-separated)
      --save                  Save successful CLI login details to entry.yaml
      --reconnect             Reconnect automatically if the session drops
      --reconnect-delay=SPEC  Delay before reconnecting

    Game selection:
      --gemstone, --gs
      --dragonrealms, --dr
      --shattered
      --fallen
      --platinum
      --test

    Frontend selection:
      --wizard
      --stormfront
      --avalon
      --frostbite
      --genie
      --saga
        Native saved Saga entries use Saga-managed Via Lich login and
        require the matching account credentials to be saved in Saga.

    Advanced launch:
      --custom-launch=NAME
      --detachable-client=PORT|auto|HOST:PORT
      --dark-mode=true|false
      --game=HOST:PORT

    Examples:
      lich --login Mychar
      lich --login Mychar --gemstone --shattered
      lich --login Mychar --frostbite
      lich --login Mychar --headless 8001
      lich --login Mychar --headless auto
      lich --login Mychar --headless tailscale:8001
      lich --login Mychar --start-scripts=repository,go2
  TEXT
end

.normalize_topic(topic) ⇒ String?

Normalizes user-facing aliases for help topic names.

Parameters:

Returns:



53
54
55
56
57
58
59
60
61
62
63
64
# File 'documented/main/help_text.rb', line 53

def self.normalize_topic(topic)
  case topic.to_s.downcase
  when '', 'overview' then nil
  when 'account', 'accounts' then 'accounts'
  when 'automation', 'automations', 'sessions', 'diagnostics' then 'automation'
  when 'login' then 'login'
  when 'path', 'paths' then 'paths'
  when 'advanced', 'compat', 'compatibility' then 'advanced'
  else
    nil
  end
end

.paths_helpString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Renders help text for the paths topic, including directory and file options.

Returns:

  • (String)

    formatted help output



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'documented/main/help_text.rb', line 208

def self.paths_help
  <<~TEXT
    Lich Help: paths

    Usage:
      lich [options]

    Path options:
      --home=PATH
      --script-dir=PATH
      --data-dir=PATH
      --temp-dir=PATH
      --map-dir=PATH
      --log-dir=PATH
      --backup-dir=PATH
      --lib-dir=PATH
      --hosts-dir=PATH
      --hosts-file=PATH

    Examples:
      lich --script-dir=/my/scripts
      lich --data-dir=/my/data --temp-dir=/tmp/lich
  TEXT
end

.render(topic = nil) ⇒ String

Returns formatted help text for the requested topic.

Parameters:

  • topic (String, nil) (defaults to: nil)

    optional topic name

Returns:

  • (String)

    rendered help output



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'documented/main/help_text.rb', line 18

def self.render(topic = nil)
  normalized_topic = normalize_topic(topic)

  case normalized_topic
  when 'login' then 
  when 'accounts' then accounts_help
  when 'automation' then automation_help
  when 'paths' then paths_help
  when 'advanced' then advanced_help
  else
    default_help
  end
end

.topic_from_argv(argv, help_arg) ⇒ String?

Resolves the topic token following --help, if any.

Parameters:

  • argv (Array<String>)

    command line arguments

  • help_arg (String)

    the matched help flag

Returns:

  • (String, nil)

    requested topic name



37
38
39
40
41
42
43
44
45
46
47
# File 'documented/main/help_text.rb', line 37

def self.topic_from_argv(argv, help_arg)
  return help_arg.split('=', 2).last if help_arg.start_with?('--help=')

  help_index = argv.index(help_arg)
  return nil if help_index.nil?

  topic = argv[help_index + 1]
  return nil if topic.nil? || topic.start_with?('--')

  topic
end