Class: MisterBin::CommandMeta
- Inherits:
-
Object
- Object
- MisterBin::CommandMeta
- 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
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#env_vars ⇒ Object
readonly
Returns the value of attribute env_vars.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#help ⇒ Object
Returns the value of attribute help.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#usages ⇒ Object
readonly
Returns the value of attribute usages.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #description ⇒ Object
- #docopt ⇒ Object
-
#initialize ⇒ CommandMeta
constructor
A new instance of CommandMeta.
- #long_description ⇒ Object
Constructor Details
#initialize ⇒ CommandMeta
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
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
10 11 12 |
# File 'lib/mister_bin/command_meta.rb', line 10 def commands @commands end |
#env_vars ⇒ Object (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 |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
10 11 12 |
# File 'lib/mister_bin/command_meta.rb', line 10 def examples @examples end |
#help ⇒ Object
Returns the value of attribute help.
11 12 13 |
# File 'lib/mister_bin/command_meta.rb', line 11 def help @help end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/mister_bin/command_meta.rb', line 10 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/mister_bin/command_meta.rb', line 10 def params @params end |
#summary ⇒ Object
Returns the value of attribute summary.
11 12 13 |
# File 'lib/mister_bin/command_meta.rb', line 11 def summary @summary end |
#usages ⇒ Object (readonly)
Returns the value of attribute usages.
10 11 12 |
# File 'lib/mister_bin/command_meta.rb', line 10 def usages @usages end |
#version ⇒ Object
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
#description ⇒ Object
30 31 32 |
# File 'lib/mister_bin/command_meta.rb', line 30 def description summary || help || '' end |
#docopt ⇒ Object
25 26 27 28 |
# File 'lib/mister_bin/command_meta.rb', line 25 def docopt [summary_string, help_string, usage_string, commands_string, , params_string, env_string, examples_string].compact.join "\n" end |
#long_description ⇒ Object
34 35 36 |
# File 'lib/mister_bin/command_meta.rb', line 34 def long_description summary && help ? "#{summary}\n\n#{help}" : description end |