Module: Lich::Main::HelpText

Defined in:
documented/main/help_text.rb

Overview

Contains help text and related methods for the Lich application.

This module provides various help topics that can be rendered based on user input.

Constant Summary collapse

HELP_TOPICS =

A list of available help topics.

Examples:

Available topics

HELP_TOPICS #=> ["login", "accounts", "automation", "paths", "advanced"]
%w[login accounts automation paths advanced].freeze

Class Method Summary collapse

Class Method Details

.accounts_helpString

Provides help text specific to account management commands.

Returns:

  • (String)

    the help text for accounts



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
# 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
      --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

Provides help text for advanced options and compatibility flags.

Returns:

  • (String)

    the help text for advanced options



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'documented/main/help_text.rb', line 227

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

    Compatibility / advanced options:
      --gui
      --no-gui
      --without-frontend
      --detachable-client=PORT
      --frontend=NAME
      --frontend-command=CMD
      --game=HOST:PORT

    Notes:
      Prefer --headless PORT or --headless auto for new headless launches.
      Compatibility flags remain supported but are intentionally omitted from the default help screen.
  TEXT
end

.automation_helpString

Provides help text specific to automation commands.

Returns:

  • (String)

    the help text for automation



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'documented/main/help_text.rb', line 183

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

Provides the default help text when no specific topic is requested.

Returns:

  • (String)

    the default help text



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'documented/main/help_text.rb', line 74

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

Provides help text specific to the login command.

Returns:

  • (String)

    the help text for login



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 102

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
      --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

    Advanced launch:
      --custom-launch=NAME
      --detachable-client=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 --start-scripts=repository,go2
  TEXT
end

.normalize_topic(topic) ⇒ String?

Normalizes the topic string to a standard format.

Parameters:

  • topic (String, nil)

    the topic to normalize

Returns:

  • (String, nil)

    the normalized topic or nil if not recognized



58
59
60
61
62
63
64
65
66
67
68
69
# File 'documented/main/help_text.rb', line 58

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

Provides help text specific to path options.

Returns:

  • (String)

    the help text for paths



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 203

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

    Usage:
      lich [options]

    Path options:
      --home=PATH
      --script-dir=PATH
      --data-dir=PATH
      --temp-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

Renders help text for a given topic.

Examples:

Render help for login

HelpText.render("login")

Parameters:

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

    the help topic to render; if nil, defaults to general help

Returns:

  • (String)

    the rendered help text



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'documented/main/help_text.rb', line 23

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?

Extracts the help topic from command-line arguments.

Parameters:

  • argv (Array<String>)

    the command-line arguments

  • help_arg (String)

    the help argument to parse

Returns:

  • (String, nil)

    the extracted topic or nil if not found



42
43
44
45
46
47
48
49
50
51
52
# File 'documented/main/help_text.rb', line 42

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