Module: Jets::Thor::Help::ClassMethods

Defined in:
lib/jets/thor/help.rb

Instance Method Summary collapse

Instance Method Details

#command_help(shell, command_name) ⇒ Object

Override command_help to include the description at the top of the long_description.



38
39
40
41
42
43
# File 'lib/jets/thor/help.rb', line 38

def command_help(shell, command_name)
  meth = normalize_command_name(command_name)
  command = all_commands[meth]
  alter_command_description(command)
  super
end

#command_list(subcommand) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/jets/thor/help.rb', line 105

def command_list(subcommand)
  list = printable_commands(true, subcommand)
  Thor::Util.thor_classes_in(self).each do |klass|
    list += klass.printable_commands(false)
  end
  list.reject! do |arr|
    c = arr[0] # IE: jets release:SUBCOMMAND
    c.include?("help") ||
      c.include?("COMMAND") ||
      c.include?("c_l_i")
  end
  sort_commands!(list)
  list
end

#help(shell, subcommand = false) ⇒ Object

override main help menu



67
68
69
70
71
72
73
# File 'lib/jets/thor/help.rb', line 67

def help(shell, subcommand = false)
  if subcommand
    help_subcommand(shell, subcommand)
  else
    help_main(shell, subcommand)
  end
end

#help_main(shell, subcommand = false) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/jets/thor/help.rb', line 81

def help_main(shell, subcommand = false)
  list = command_list(subcommand)

  filter = proc do |command, desc|
    main_commands.detect { |name| command =~ Regexp.new("^jets #{name}") }
  end
  main = list.select(&filter)
  other = list.reject(&filter)

  shell.say "Usage: jets COMMAND [args]"
  shell.say "\nMain Commands:\n\n"
  shell.print_table(main, indent: 2, truncate: true)
  shell.say "\nOther Commands:\n\n"
  shell.print_table(other, indent: 2, truncate: true)
  shell.say <<~EOL

    For more help on each command, you can use the -h option. Example:

      jets deploy -h

    CLI Reference also available at: https://docs.rubyonjets.com/reference/
  EOL
end

#help_subcommand(shell, subcommand) ⇒ Object



75
76
77
78
79
# File 'lib/jets/thor/help.rb', line 75

def help_subcommand(shell, subcommand)
  list = command_list(subcommand)
  shell.say "Commands:\n\n"
  shell.print_table(list, indent: 2, truncate: true)
end

#main_commandsObject



120
121
122
123
124
125
126
# File 'lib/jets/thor/help.rb', line 120

def main_commands
  %w[
    deploy
    logs
    url
  ]
end