Class: G2R::Util::CommandLineParser
- Inherits:
-
Object
- Object
- G2R::Util::CommandLineParser
- Defined in:
- lib/graph2relational/util-commandline-parser.rb
Instance Method Summary collapse
-
#initialize ⇒ CommandLineParser
constructor
A new instance of CommandLineParser.
- #parse ⇒ Object
Constructor Details
#initialize ⇒ CommandLineParser
Returns a new instance of CommandLineParser.
6 7 8 |
# File 'lib/graph2relational/util-commandline-parser.rb', line 6 def initialize() @valid = true end |
Instance Method Details
#parse ⇒ Object
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/graph2relational/util-commandline-parser.rb', line 10 def parse() # default values = {:input => nil, :output => nil, :exclude => []} # display help if no args ARGV << '-h' if ARGV.empty? # do parsing OptionParser.new do |opts| opts. = "Usage: graph2relational -i <neo4j_connection_url> -o <rdbms_connection_url> [optional_arguments]" # input file opts.on("-i CONNECTION", "--input CONNECTION", "Neo4J connection URI from where the schema and data will be geberated") do |input_connection| [:input] = input_connection end # output dir opts.on("-o CONNECTION", "--output CONNECTION", "RDBMS connection URI to where the schema and data will be persisted") do |output_connection| [:output] = output_connection end # exclusion opts.on("-x EXCLUSION", "--exclude EXCLUSION", "Neo4J labels (separated by comma) to exclude from the conversion") do |exclude| [:exclude] = exclude.split(",").map{|exclude| exclude.strip} end # help opts.on_tail("-h", "--help", "Help message") do puts opts exit end end.parse! # check mandatory args if [:input].nil? puts "Missing parameter: specify Neo4J connection URI using -i <connection> parameter" exit end if [:output].nil? puts "Missing parameter: specify RDBMS connection URI using -o <connection> parameter" exit end return end |