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
- #db_name ⇒ Object
-
#db_name? ⇒ Boolean
lets us check if user passed in db settings.
- #db_path ⇒ 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.
7 8 9 |
# File 'lib/pluto/cli/opts.rb', line 7 def initialize load_shortcuts end |
Instance Method Details
#config_path ⇒ Object
56 57 58 59 |
# File 'lib/pluto/cli/opts.rb', line 56 def config_path ## @config_path || '~/.pluto' --- old code @config_path || File.join( Env.home, '.pluto' ) end |
#config_path=(value) ⇒ Object
52 53 54 |
# File 'lib/pluto/cli/opts.rb', line 52 def config_path=(value) @config_path = value end |
#db_name ⇒ Object
38 |
# File 'lib/pluto/cli/opts.rb', line 38 def db_name() @db_name || 'pluto.db' ; end |
#db_name? ⇒ Boolean
lets us check if user passed in db settings
35 |
# File 'lib/pluto/cli/opts.rb', line 35 def db_name?() @db_name.present? ; end |
#db_path ⇒ Object
37 |
# File 'lib/pluto/cli/opts.rb', line 37 def db_path() @db_path || '.' ; end |
#load_shortcuts ⇒ Object
70 71 72 73 |
# File 'lib/pluto/cli/opts.rb', line 70 def load_shortcuts ### Note: for now shortcuts packed w/ pluto-merge - move to pluto (this gem??) why? why not? @shortcuts = YAML.load_file( "#{PlutoMerge.root}/config/pluto.index.yml" ) end |
#manifest ⇒ Object
42 |
# File 'lib/pluto/cli/opts.rb', line 42 def manifest() @manifest || 'blank' ; end |
#manifest=(value) ⇒ Object
41 |
# File 'lib/pluto/cli/opts.rb', line 41 def manifest=(value) @manifest = value; end |
#map_fetch_shortcut(key) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/pluto/cli/opts.rb', line 75 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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pluto/cli/opts.rb', line 12 def ( ={} ) @verbose = true if [:verbose] == true @db_path = [:dbpath] if [:dbpath].present? if [:dbname].present? ########## # note: c.default_value '<PLANET>.db e.g. ruby.db' # gli2 will set default if present - thus, do NOT set a default value # otherwise it will get set @db_name = [:dbname] puts "setting opts.db_name to '#{options[:dbname]}'" end @config_path = [:config] if [:config].present? @output_path = [:output] if [:output].present? @manifest = [:template] if [:template].present? end |
#output_path ⇒ Object
66 67 68 |
# File 'lib/pluto/cli/opts.rb', line 66 def output_path @output_path || '.' end |
#output_path=(value) ⇒ Object
62 63 64 |
# File 'lib/pluto/cli/opts.rb', line 62 def output_path=(value) @output_path = value end |
#verbose=(value) ⇒ Object
44 45 46 |
# File 'lib/pluto/cli/opts.rb', line 44 def verbose=(value) @verbose = true # note: always assumes true for now; default is false end |
#verbose? ⇒ Boolean
48 49 50 |
# File 'lib/pluto/cli/opts.rb', line 48 def verbose? @verbose || false end |