Class: Pluto::Opts
- Inherits:
-
Object
- Object
- Pluto::Opts
- Defined in:
- lib/pluto/cli/opts.rb
Instance Method Summary collapse
- #config_path ⇒ Object
- #config_path=(value) ⇒ Object
-
#initialize ⇒ Opts
constructor
A new instance of Opts.
- #load_shortcuts ⇒ Object
- #manifest ⇒ Object
- #manifest=(value) ⇒ Object
- #map_fetch_shortcut(key) ⇒ Object
- #merge_gli_options!(options = {}) ⇒ Object
- #output_path ⇒ Object
- #output_path=(value) ⇒ Object
- #verbose=(value) ⇒ Object
- #verbose? ⇒ Boolean
Constructor Details
#initialize ⇒ Opts
Returns a new instance of Opts.
5 6 7 |
# File 'lib/pluto/cli/opts.rb', line 5 def initialize load_shortcuts end |
Instance Method Details
#config_path ⇒ Object
40 41 42 43 |
# File 'lib/pluto/cli/opts.rb', line 40 def config_path ## @config_path || '~/.pluto' --- old code @config_path || File.join( Env.home, '.pluto' ) end |
#config_path=(value) ⇒ Object
36 37 38 |
# File 'lib/pluto/cli/opts.rb', line 36 def config_path=(value) @config_path = value end |
#load_shortcuts ⇒ Object
54 55 56 |
# File 'lib/pluto/cli/opts.rb', line 54 def load_shortcuts @shortcuts = YAML.load_file( "#{Pluto.root}/config/pluto.index.yml" ) end |
#manifest ⇒ Object
24 25 26 |
# File 'lib/pluto/cli/opts.rb', line 24 def manifest @manifest || 'blank' end |
#manifest=(value) ⇒ Object
20 21 22 |
# File 'lib/pluto/cli/opts.rb', line 20 def manifest=(value) @manifest = value end |
#map_fetch_shortcut(key) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/pluto/cli/opts.rb', line 58 def map_fetch_shortcut( key ) # NB: always returns an array!!! 0,1 or more entries # - no value - return empty ary ## todo: normalize key??? value = @shortcuts.fetch( key, nil ) if value.nil? [] elsif value.kind_of?( String ) [value] else # assume it's an array already; ## todo: check if it's an array value end end |
#merge_gli_options!(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/pluto/cli/opts.rb', line 10 def ( ={} ) @verbose = true if [:verbose] == true @config_path = [:config] if [:config].present? @output_path = [:output] if [:output].present? @manifest = [:template] if [:template].present? end |
#output_path ⇒ Object
50 51 52 |
# File 'lib/pluto/cli/opts.rb', line 50 def output_path @output_path || '.' end |
#output_path=(value) ⇒ Object
46 47 48 |
# File 'lib/pluto/cli/opts.rb', line 46 def output_path=(value) @output_path = value end |
#verbose=(value) ⇒ Object
28 29 30 |
# File 'lib/pluto/cli/opts.rb', line 28 def verbose=(value) @verbose = true # note: always assumes true for now; default is false end |
#verbose? ⇒ Boolean
32 33 34 |
# File 'lib/pluto/cli/opts.rb', line 32 def verbose? @verbose || false end |