Module: Pray::CLI::Help

Defined in:
lib/pray/cli/help.rb

Constant Summary collapse

WORKFLOW_COMMANDS =
[
  "install [--locked|--frozen|--offline]  resolve, render, and write Prayfile.lock",
  "plan [--remote]                        preview materialization changes",
  "apply                                  apply the current plan",
  "verify [--strict]                      check rendered output against the lockfile",
  "drift [--semantic]                     compare lockfile to current resolution",
  "render [--check]                       render targets without updating the lockfile",
  "format, fmt                            rewrite Prayfile to recommended destination DSL"
].freeze
PACKAGE_COMMANDS =
[
  "add <name> [constraint] [--path PATH]  declare a package in Prayfile",
  "remove <name>                          remove a package from Prayfile",
  "update [package] [--major] [--latest] [--dry-run] [--json]",
  "unlock <package>                       clear a locked package pin",
  "vendor                                 copy resolved packages locally",
  "clean                                  remove local cache and vendor trees"
].freeze
DISTRIBUTION_COMMANDS =
[
  "publish --root PATH [--server URL ...]",
  "login --server URL --email EMAIL",
  "serve [--root PATH] [--host HOST] [--port PORT] [--stdio]",
  "sync [--root PATH] [--peer URL ...]",
  "confess <package> | --from-lock SPAN_ID [--accepted|--rejected]"
].freeze
TRUST_COMMANDS =
[
  "trust list|show|add-key|remove-key|set-signed|set-allow|import-repo|import-registry|check"
].freeze
INSPECT_COMMANDS =
[
  "list                                   list declared packages",
  "outdated [--remote]                    show constraint vs resolved versions",
  "explain <package>                      show why a package was selected",
  "tree                                   print the dependency tree"
].freeze
META_COMMANDS =
[
  "init [--targets tool_a,tool_b]         create a starter Prayfile",
  "prayer init                            scaffold a prayer package",
  "repo init                              scaffold a distribution root",
  "manifest                               print canonical Prayfile JSON",
  "package                                build a distributable prayer archive",
  "version | -V | --version               print the pray CLI version"
].freeze
GLOBAL_OPTIONS =
[
  "--no-input            disable prompts",
  "--rm                  use an ephemeral home directory",
  "--trust [--global]    import trust on first use"
].freeze
COMMAND_HELP =
{
  "install" => <<~TEXT.strip,
  "verify" => <<~TEXT.strip,
  "drift" => <<~TEXT.strip,
  "render" => <<~TEXT.strip,
  "format" => <<~TEXT.strip,
  "fmt" => <<~TEXT.strip,
  "update" => <<~TEXT.strip,
  "plan" => <<~TEXT.strip,
  "apply" => "materialize the current resolution plan\n\nUsage: pray apply",
  "add" => <<~TEXT.strip,
  "remove" => "remove a package from Prayfile\n\nUsage: pray remove <name>",
  "unlock" => "clear a locked package pin\n\nUsage: pray unlock <package>",
  "vendor" => "copy resolved packages locally\n\nUsage: pray vendor",
  "clean" => "remove local cache and vendor trees\n\nUsage: pray clean",
  "publish" => <<~TEXT.strip,
  "login" => <<~TEXT.strip,
  "serve" => <<~TEXT.strip,
  "sync" => <<~TEXT.strip,
  "confess" => <<~TEXT.strip,
  "trust" => <<~TEXT.strip,
  "list" => "list declared packages\n\nUsage: pray list",
  "outdated" => <<~TEXT.strip,
  "explain" => <<~TEXT.strip,
  "tree" => "print the dependency tree\n\nUsage: pray tree",
  "init" => <<~TEXT.strip,
  "prayer" => "scaffold a prayer package\n\nUsage: pray prayer init",
  "repo" => "scaffold a distribution root\n\nUsage: pray repo init",
  "manifest" => "print canonical Prayfile JSON\n\nUsage: pray manifest",
  "package" => "build a distributable prayer archive\n\nUsage: pray package",
  "version" => <<~TEXT.strip,
  "help" => <<~TEXT.strip
    show help for pray or one command

    Usage: pray help [command]
           pray [command] --help
  TEXT
}.freeze

Class Method Summary collapse

Class Method Details



218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/pray/cli/help.rb', line 218

def print_command_groups
  print_group("Workflow", WORKFLOW_COMMANDS)
  puts
  print_group("Packages", PACKAGE_COMMANDS)
  puts
  print_group("Distribution", DISTRIBUTION_COMMANDS)
  puts
  print_group("Trust", TRUST_COMMANDS)
  puts
  print_group("Inspect", INSPECT_COMMANDS)
  puts
  print_group("Meta", META_COMMANDS)
end


210
211
212
213
214
215
216
# File 'lib/pray/cli/help.rb', line 210

def print_command_help(command)
  text = COMMAND_HELP[command]
  return false unless text

  puts text
  true
end


190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/pray/cli/help.rb', line 190

def print_concise_help
  puts "Usage: pray [OPTIONS] <COMMAND>"
  puts
  puts "Declare shared instructions in Prayfile, lock versions, and render tool-specific output."
  puts
  puts "Getting started:"
  puts "  pray init"
  puts "  pray install"
  puts "  pray plan"
  puts "  pray apply"
  puts "  pray verify"
  puts
  print_command_groups
  puts
  puts "Options:"
  GLOBAL_OPTIONS.each { |line| puts "  #{line}" }
  puts
  puts "See 'pray help <command>' or 'pray <command> --help' for details on a command."
end


232
233
234
235
# File 'lib/pray/cli/help.rb', line 232

def print_group(title, lines)
  puts "#{title}:"
  lines.each { |line| puts "  #{line}" }
end