Class: Zenflow::Help

Inherits:
Object
  • Object
show all
Defined in:
lib/zenflow/helpers/help.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Help

Returns a new instance of Help.



10
11
12
# File 'lib/zenflow/helpers/help.rb', line 10

def initialize(options={})
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/zenflow/helpers/help.rb', line 8

def options
  @options
end

Instance Method Details



18
19
20
21
22
23
24
25
# File 'lib/zenflow/helpers/help.rb', line 18

def banner
  help = []
  help << "#{title("Summary")}\n#{options[:summary]}" if options[:summary]
  help << "#{title("Usage")}\n#{options[:usage]}" if options[:usage]
  help << "#{title("Available Commands")}\n#{options[:commands]}" if options[:commands]
  help << "#{title("Options")}"
  help.join("\n\n")
end

#title(text) ⇒ Object



14
15
16
# File 'lib/zenflow/helpers/help.rb', line 14

def title(text)
  "- #{text} ".ljust(40, "-").cyan
end

#unknown_commandObject



27
28
29
30
31
32
33
34
# File 'lib/zenflow/helpers/help.rb', line 27

def unknown_command
  if options[:command].nil?
    Zenflow::Log("Missing command", :color => :red)
  else
    Zenflow::Log("Unknown command #{options[:command].inspect}", :color => :red)
  end
  exit(1)
end