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.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mister_bin/command_meta.rb', line 12 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.
9 10 11 |
# File 'lib/mister_bin/command_meta.rb', line 9 def commands @commands end |
#env_vars ⇒ Object (readonly)
Returns the value of attribute env_vars.
9 10 11 |
# File 'lib/mister_bin/command_meta.rb', line 9 def env_vars @env_vars end |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
9 10 11 |
# File 'lib/mister_bin/command_meta.rb', line 9 def examples @examples end |
#help ⇒ Object
Returns the value of attribute help.
10 11 12 |
# File 'lib/mister_bin/command_meta.rb', line 10 def help @help end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/mister_bin/command_meta.rb', line 9 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
9 10 11 |
# File 'lib/mister_bin/command_meta.rb', line 9 def params @params end |
#summary ⇒ Object
Returns the value of attribute summary.
10 11 12 |
# File 'lib/mister_bin/command_meta.rb', line 10 def summary @summary end |
#usages ⇒ Object (readonly)
Returns the value of attribute usages.
9 10 11 |
# File 'lib/mister_bin/command_meta.rb', line 9 def usages @usages end |
#version ⇒ Object
Returns the value of attribute version.
10 11 12 |
# File 'lib/mister_bin/command_meta.rb', line 10 def version @version end |
Instance Method Details
#description ⇒ Object
31 32 33 |
# File 'lib/mister_bin/command_meta.rb', line 31 def description summary || help || '' end |
#docopt ⇒ Object
24 25 26 27 28 29 |
# File 'lib/mister_bin/command_meta.rb', line 24 def docopt [ summary_string, help_string, usage_string, commands_string, , params_string, env_string, examples_string ].compact.join "\n" end |
#long_description ⇒ Object
35 36 37 |
# File 'lib/mister_bin/command_meta.rb', line 35 def long_description summary && help ? "#{summary}\n\n#{help}" : description end |