Sha256: aa16ae0b6ef49be5dbb944d0341971bf1e34cffc421ff046caa8d5125b5764ea
Contents?: true
Size: 1.07 KB
Versions: 17
Compression:
Stored size: 1.07 KB
Contents
module Eco class Scripting module Lib def is_modifier?(value) value&.start_with?("-") end def get_arg(key, with_param: false, valid: true) return nil if !ARGV.include?(key) value = true if with_param next_i = ARGV.index(key) + 1 value = ARGV[next_i] #puts "modifier argument: #{value}" value = nil if valid && is_modifier?(value) end return value end def get_file(key, required: false, should_exist: true) filename = get_arg(key, with_param: true) if !filename if required puts "you need to specify a file '#{key} file'" exit end elsif !(File.exists?(filename) || File.exists?(File.expand_path(filename))) if should_exist && required puts "file doesn't exist #{filename}" exit end end filename = File.expand_path(filename) if filename && should_exist filename end end end end
Version data entries
17 entries across 17 versions & 1 rubygems