Class: ExtJS::XTheme::Command::Help

Inherits:
Base
  • Object
show all
Defined in:
lib/extjs-xtheme/commands/help.rb

Defined Under Namespace

Classes: HelpGroup

Instance Attribute Summary

Attributes inherited from Base

#args, #config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#ask, #display, #error, #escape, #extract_app, #extract_app_in_dir, #extract_option, #heroku, #initialize, #shell

Constructor Details

This class inherits a constructor from ExtJS::XTheme::Command::Base

Class Method Details

.create_default_groups!Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/extjs-xtheme/commands/help.rb', line 31

def self.create_default_groups!
  group('General Commands') do
    command 'help',                         'show this usage'
    #command 'version',                      'show the gem version'
    space
    #command 'list',                         'list your themes'
    command 'create [<name>]',              'create a new theme'
    space
    #command 'config',                       'display the theme\'s config vars (environment)'
    #command 'config:add key=val [...]',     'add one or more config vars'
    #space
    #command 'destroy [<name>]',             'destroy a theme permanently'
  end

  group('Effects') do
    command 'effects:modulate [<theme> <hue> <saturation> <lightness>]', 'Apply hue, saturation, lightness to a themes\'s images.  Specify as Floats, where 1.0 means 100%'
    space
  end
end

.group(title, &block) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/extjs-xtheme/commands/help.rb', line 23

def self.group(title, &block)
  groups << begin
    group = HelpGroup.new(title)
    group.instance_eval(&block)
    group
  end
end

.groupsObject



19
20
21
# File 'lib/extjs-xtheme/commands/help.rb', line 19

def self.groups
  @groups ||= []
end

Instance Method Details

#indexObject



51
52
53
# File 'lib/extjs-xtheme/commands/help.rb', line 51

def index
  display usage
end

#usageObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/extjs-xtheme/commands/help.rb', line 59

def usage
  longest_command_length = self.class.groups.map do |group|
    group.map { |g| g.first.length }
  end.flatten.max

  self.class.groups.inject(StringIO.new) do |output, group|
    output.puts "=== %s" % group.title
    output.puts

    group.each do |command, description|
      if command.empty?
        output.puts
      else
        output.puts "%-*s # %s" % [longest_command_length, command, description]
      end
    end

    output.puts
    output
  end.string
end

#versionObject



55
56
57
# File 'lib/extjs-xtheme/commands/help.rb', line 55

def version
  #display ExtJS::XTheme.version
end