Method: Docgen::CLI.execute

Defined in:
lib/docgen/cli.rb

.execute(stdout, arguments = []) ⇒ Object



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/docgen/cli.rb', line 207

def self.execute(stdout, arguments=[])
  # NOTE: the option -p/--path= is given as an example, and should be replaced in your application.
  options = {
    :path     => '~'
  }
  mandatory_options = %w(  )
  parser = OptionParser.new do |opts|
    opts.banner = <<-BANNER.gsub(/^          /,'')
      Generate HTML Doc for SQL

      Usage: #{File.basename($0)} [options]

      Options are:
    BANNER
    opts.separator ""
    opts.on("-s", "--source=Source", String,
            "The input SQL file.") { |arg| options[:source] = arg }
    opts.on("-h", "--help",
            "Show this help message.") { stdout.puts opts; exit }
    opts.parse!(arguments)

    if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
      stdout.puts opts; exit
    end
  end

  source = options[:source]

  # do stuff
  if source
    read_sql_file( source )
  else
    print "Must specify an input SQL file\n"
  end
end