Class: Tweetwine::CLI::HelpCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/tweetwine/cli.rb

Instance Method Summary collapse

Methods inherited from Command

abort_with_usage, about, inherited, #initialize, name, register, show_usage, usage

Constructor Details

This class inherits a constructor from Tweetwine::CLI::Command

Instance Method Details

#parse(args) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/tweetwine/cli.rb', line 213

def parse(args)
  # Did we arrive here via '-h' option? If so, we cannot have
  # +proposed_command+ because '-h' does not take an argument. Otherwise,
  # try to read the argument.
  proposed_command = args.include?('-h') ? nil : args.shift
  if proposed_command
    @command = CLI.find_command proposed_command
    CLI.ui.error "unknown command: #{proposed_command}\n\n" unless @command
    @command
  else
    @command = nil
    true
  end
end

#runObject



228
229
230
231
232
233
234
# File 'lib/tweetwine/cli.rb', line 228

def run
  if @command
    show_command_help
  else
    show_general_help
  end
end