Class: MisterBin::CommandMeta

Inherits:
Object
  • Object
show all
Includes:
Colsole
Defined in:
lib/mister_bin/command_meta.rb

Overview

This class is responsible for holding all the meta data for a command and for generating a text string ready to be used by Docopt.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandMeta

Returns a new instance of CommandMeta.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mister_bin/command_meta.rb', line 13

def initialize
  @version  = nil
  @help     = nil
  @summary  = nil
  @usages   = []
  @options  = []
  @params   = []
  @commands = []
  @examples = []
  @env_vars = []
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



10
11
12
# File 'lib/mister_bin/command_meta.rb', line 10

def commands
  @commands
end

#env_varsObject (readonly)

Returns the value of attribute env_vars.



10
11
12
# File 'lib/mister_bin/command_meta.rb', line 10

def env_vars
  @env_vars
end

#examplesObject (readonly)

Returns the value of attribute examples.



10
11
12
# File 'lib/mister_bin/command_meta.rb', line 10

def examples
  @examples
end

#helpObject

Returns the value of attribute help.



11
12
13
# File 'lib/mister_bin/command_meta.rb', line 11

def help
  @help
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/mister_bin/command_meta.rb', line 10

def options
  @options
end

#paramsObject (readonly)

Returns the value of attribute params.



10
11
12
# File 'lib/mister_bin/command_meta.rb', line 10

def params
  @params
end

#summaryObject

Returns the value of attribute summary.



11
12
13
# File 'lib/mister_bin/command_meta.rb', line 11

def summary
  @summary
end

#usagesObject (readonly)

Returns the value of attribute usages.



10
11
12
# File 'lib/mister_bin/command_meta.rb', line 10

def usages
  @usages
end

#versionObject

Returns the value of attribute version.



11
12
13
# File 'lib/mister_bin/command_meta.rb', line 11

def version
  @version
end

Instance Method Details

#descriptionObject



30
31
32
# File 'lib/mister_bin/command_meta.rb', line 30

def description
  summary || help || ''
end

#docoptObject



25
26
27
28
# File 'lib/mister_bin/command_meta.rb', line 25

def docopt
  [summary_string, help_string, usage_string, commands_string,
    options_string, params_string, env_string, examples_string].compact.join "\n"
end

#long_descriptionObject



34
35
36
# File 'lib/mister_bin/command_meta.rb', line 34

def long_description
  summary && help ? "#{summary}\n\n#{help}" : description
end