Class: ItunesConnect::Commands::Help

Inherits:
Object
  • Object
show all
Defined in:
lib/itunes_connect/commands/help.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(c) ⇒ Help

Returns a new instance of Help.



5
6
7
# File 'lib/itunes_connect/commands/help.rb', line 5

def initialize(c)
  # nothing to do here
end

Instance Method Details

#descriptionObject



27
28
29
# File 'lib/itunes_connect/commands/help.rb', line 27

def description
  "Describe a particular command"
end

#execute!(opts = { }, args = [], out = $stdout) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/itunes_connect/commands/help.rb', line 9

def execute!(opts={ }, args=[], out=$stdout)
  if args.empty?
    out.puts "Available commands:"
    out.puts
    ItunesConnect::Commands.all.each do |cmd|
      out.printf("%-9s %s\n",
                 cmd.to_s.split('::').last.downcase,
                 cmd.new(Clip::Parser.new).description)
    end
  else
    cli = ItunesConnect::Commands.default_clip
    cmd = ItunesConnect::Commands.for_name(args.first, cli)
    cli.banner = "Command options for '#{cmd.class.to_s.split('::').last.downcase}':"
    raise ArgumentError.new("Unrecognized command '#{args.first}'") if cmd.nil?
    out.puts(cli.help)
  end
end