Commit 14d8372d authored by Cyril Rohr's avatar Cyril Rohr
Browse files

better doc and error handling

parent c5b004df
......@@ -10,10 +10,12 @@ usage = %{
A tool to generate the Grid5000 reference data.
Usage:
ruby grid5000.rb [input files] [options]
ruby grid5000.rb [input files] [config files] [options]
Options:
-s : simulation mode
Notes:
input files must be RUBY files and end with a .rb extension.
config files mst be YAML files and end with a .yaml extension.
}
# true if we want to simulate:
......@@ -21,10 +23,10 @@ simulation_mode = !$*.delete("-s").nil?
if $*.empty?
puts usage
exit -1
elsif ($*.map{|file| File.exists?(file) && (File.extname(file) == ".rb" || File.extname(file) == ".yaml")}.include? false)
puts "Error: your input files do not exist or are not ruby files (.rb extension) or config files (.yaml extension)."
exit -1
exit 1
elsif ($*.map{|file| File.exists?(file)}.include? false)
puts "Error: one of your input file do not exist."
exit 2
else
description_files = $*
input = {}
......
......@@ -65,8 +65,9 @@ class ReferenceGenerator
Resolv.getaddress(network_address)
end
# Lookup a key in one of the configuration files passed to the generator
#
# usage:
# Usage:
# lookup('nancy', 'nodes', 'paramount-1', 'property_name')
# or
# lookup('nancy', 'nodes') { |result| result['paramount-1']['property_name'] }
......@@ -158,7 +159,8 @@ class ReferenceGenerator
# Initializes a new generator that will generate data files in a hierachical way.
# The root of the tree will be named with the value of <tt>data_description[:uid]</tt>.
def initialize(data_description = {:uid => ""}, options = {:input => {}, :config => {}})
@input = options[:input] || raise(ArgumentError, "INPUT cannot be null.")
@input = options[:input]
raise(ArgumentError, "INPUT cannot be null or empty.") if input.nil? || input.empty?
@config = options[:config] || {}
@data = G5K::Tree.new.replace(data_description)
@context = @data
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment