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 =

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

Valid help topic names.

%w[login accounts automation paths advanced].freeze

Class Method Summary collapse

Class Method Details

.accounts_help ⇒ String

Returns help text for the accounts topic.

Returns:

  • (String) —

    formatted help output covering account management commands, encryption modes, and game codes



152
153
154
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
182
183
184
185
186
187
188
# File 'documented/main/help_text.rb', line 152

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

    Usage:
      lich [account command] [options]

    Commands:
      --add-account ACCOUNT PASSWORD
      --refresh-characters ACCOUNT [--frontend FRONTEND]
      --add-character ACCOUNT CHAR_NAME --game-code CODE [--frontend FRONTEND]
      --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

    Game codes (--game-code):
      GS3  GemStone IV              DR   DragonRealms
      GST  GemStone IV Prime Test   DRX  DragonRealms Platinum
      GSF  GemStone IV Shattered    DRT  DragonRealms Prime Test
                                    DRF  DragonRealms Fallen

    Examples:
      lich --add-account MYACCOUNT MYPASSWORD --frontend stormfront
      lich --refresh-characters MYACCOUNT
      lich --add-character MYACCOUNT NewCharName --game-code DR
      lich --change-account-password MYACCOUNT NEWPASSWORD
      lich --convert-entries enhanced
      lich --change-encryption-mode enhanced --master-password SECRET
  TEXT
end

.advanced_help ⇒ String

Returns help text for the advanced topic.

Returns:

  • (String) —

    formatted help output covering compatibility options, GUI control, and network binding



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'documented/main/help_text.rb', line 257

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_help ⇒ String

Returns help text for the automation topic.

Returns:

  • (String) —

    formatted help output covering active session discovery and configuration



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'documented/main/help_text.rb', line 193

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

    Notes:
      Active session discovery coordinates through TEMP_DIR by default. If
      each character uses a separate --temp-dir, pass a shared
      --active-session-dir=PATH so all characters coordinate through one
      directory instead of isolated per-character ones.

      Passing --active-session-dir=PATH also enables the active sessions
      service for that launch, even if it isn't persistently enabled.
      This is a per-launch opt-in only -- it persists no setting, so
      omitting the flag on a later launch reverts to the persisted
      setting (disabled by default). The service itself still writes
      coordination files (a lock and a discovery record) into the
      directory while it runs.
  TEXT
end

.default_help ⇒ String

Returns the default help text shown when no topic is specified.

Returns:

  • (String) —

    formatted help output with usage examples and available topics



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

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_help ⇒ String

Returns help text for the login topic.

Returns:

  • (String) —

    formatted help output covering login options, game selection, frontend selection, and advanced launch modes



97
98
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
# File 'documented/main/help_text.rb', line 97

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_help ⇒ String

Returns help text for the paths topic.

Returns:

  • (String) —

    formatted help output covering directory and file path configuration options



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'documented/main/help_text.rb', line 227

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
      --active-session-dir=PATH

    Examples:
      lich --script-dir=/my/scripts
      lich --data-dir=/my/data --temp-dir=/tmp/lich
      lich --temp-dir=/tmp/lich-Mychar --active-session-dir=/tmp/lich-sessions
  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