Class: Rouge::CLI::Help

Inherits:
Rouge::CLI show all
Defined in:
lib/rouge/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rouge::CLI

class_from_arg, error!, #error!, normalize_syntax

Constructor Details

#initialize(opts = {}) ⇒ Help


152
153
154
# File 'lib/rouge/cli.rb', line 152

def initialize(opts={})
  @mode = opts[:mode]
end

Class Method Details

.descObject


127
128
129
# File 'lib/rouge/cli.rb', line 127

def self.desc
  "print help info"
end

.doc {|%|usage: rougify help <command>|| ... } ⇒ Object

Yields:

  • (%|usage: rougify help <command>|)

131
132
133
134
135
136
137
# File 'lib/rouge/cli.rb', line 131

def self.doc
  return enum_for(:doc) unless block_given?

  yield %|usage: rougify help <command>|
  yield %||
  yield %|print help info for <command>.|
end

.parse(argv) ⇒ Object


139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/rouge/cli.rb', line 139

def self.parse(argv)
  opts = { :mode => CLI }
  until argv.empty?
    arg = argv.shift
    klass = class_from_arg(arg)
    if klass
      opts[:mode] = klass
      next
    end
  end
  new(opts)
end

Instance Method Details

#runObject


156
157
158
# File 'lib/rouge/cli.rb', line 156

def run
  @mode.doc.each(&method(:puts))
end