Class: Flow::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/flow-lite.rb

Class Method Summary collapse

Class Method Details

.main(args = ARGV) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/flow-lite.rb', line 186

def self.main( args=ARGV )
  options = {}
  OptionParser.new do |parser|
    parser.on( '-f FILENAME', '--flowfile FILENAME' ) do |filename|
      options[:flowfile] = filename
    end

    ## note:

    ##  you can add many/multiple modules

    ##  e.g. -r gitti -r mono etc.

    parser.on( '-r NAME', '--require NAME') do |name|
      options[:requires] ||= []
      options[:requires] << name
    end
  end.parse!( args )


  ## check for any (dynamic/auto) requires

  if options[:requires]
    names = options[:requires]
    names.each do |name|
      ## todo/check: add some error/exception handling here - why? why not?

      puts "[flow] (auto-)require >#{name}<..."
      require( name )
    end
  end


  path = options[:flowfile] || Flowfile.find_file


  puts "[flow] loading >#{path}<..."
  flowfile = Flowfile.load_file( path )


  ## allow multipe steps getting called - why? why not?

  ##   flow setup clone update   etc??

  args.each do |arg|
    flowfile.run( arg )
  end
end