Class: GephiKeeper::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/gephi_keeper/cli.rb

Class Method Summary collapse

Class Method Details

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



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gephi_keeper/cli.rb', line 6

def self.execute(stdout, arguments=[])

  # Defaults for options
  options = {
    :filename     => nil
  }
  mandatory_options = [ :filename ]

  parser = OptionParser.new do |opts|
    opts.banner = "      Convert tweets from Twitter, output as JSON from TwapperKeeper (www.twapperkeeper.com) into GEXF format for the Gephi graphviz tool. (www.gephi.org)\n\n      Usage: \#{File.basename($0)} [options]\n\n      Options are:\n    BANNER\n    opts.separator \"\"\n    opts.on(\"-f\", \"--filename FILENAME\", String,\n            \"Name of input file.\") { |arg| options[:filename] = arg }\n    opts.on(\"-h\", \"--help\",\n            \"Show this help message.\") { stdout.puts opts; exit }\n    opts.parse!(arguments)\n    # Check for mandatory options\n    if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }\n      stdout.puts opts; exit\n    end\n  end\n\n  filename = options[:filename]\n\n  # do stuff\n  #stdout.puts \"To update this executable, look in lib/gephi_keeper/cli.rb\"\n  GephiKeeper::Base.process_file( :filename => filename )\nend\n".gsub(/^          /,'')