Class: Khaleesi::CLI::Help

Inherits:
Khaleesi::CLI show all
Defined in:
lib/khaleesi/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Khaleesi::CLI

class_from_arg, #create_file_p, normalize_syntax

Constructor Details

#initialize(opts = {}) ⇒ Help

Returns a new instance of Help.



579
580
581
# File 'lib/khaleesi/cli.rb', line 579

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

Class Method Details

.descObject



554
555
556
# File 'lib/khaleesi/cli.rb', line 554

def self.desc
  'print help info'
end

.doc {|'usage: khaleesi help <command>'| ... } ⇒ Object

Yields:

  • ('usage: khaleesi help <command>')


558
559
560
561
562
563
564
# File 'lib/khaleesi/cli.rb', line 558

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

  yield 'usage: khaleesi help <command>'
  yield ''
  yield 'print help info for <command>.'
end

.parse(argv) ⇒ Object



566
567
568
569
570
571
572
573
574
575
576
577
# File 'lib/khaleesi/cli.rb', line 566

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



583
584
585
# File 'lib/khaleesi/cli.rb', line 583

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