Class: Duse::CLI::Help

Inherits:
Command show all
Defined in:
lib/duse/cli/help.rb

Instance Attribute Summary

Attributes inherited from Command

#arguments, #force_interactive, #input, #output

Instance Method Summary collapse

Methods inherited from Command

abstract, abstract?, #check_arity, #color, #command_name, command_name, #config, description, #error, #execute, #format, #full_command, full_command, has_subcommands?, has_super_command?, #help, #help_subcommands, #initialize, #interactive?, #parse, #say, #setup, skip, subcommand, subcommands, #success, super_command, super_command=, #terminal, #usage, #usage_for, #warn, #write_to, #wrong_args

Methods included from Parser

#new, #on, #on_initialize

Constructor Details

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

Instance Method Details

#commandsObject



18
19
20
# File 'lib/duse/cli/help.rb', line 18

def commands
  CLI.commands.sort_by { |c| c.command_name }
end

#run(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/duse/cli/help.rb', line 8

def run(*args)
  unless args.empty?
    say CLI.command(args).new.help
  else
    say "Usage: duse COMMAND ...\n\nAvailable commands:\n\n"
    commands.each { |c| say "\t#{color(c.command_name, :command).ljust(22)} #{color(c.description, :info)}" }
    say "\nrun `duse help COMMAND` for more infos"
  end
end