Sha256: 2f160b19cd94827b7c4258182c83135a4e931bd025e76a5c932f96b59ec6b20e
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
#!/usr/bin/env ruby $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'optparse' require 'jeka' TOP_MSG = "jeka v#{File.open(File.join(File.dirname(__FILE__), '..', 'VERSION'), "r").readlines.join}" puts TOP_MSG options = {} run_optparse = OptionParser.new do |opts| opts.banner = "Usage: jeka run [options] file ..." options[:n] = 1 opts.on '-n', '--n-repetitions N', Integer, 'Number of repetions' do |n| options[:n] = n end end build_optparse = OptionParser.new do |opts| opts.banner = "Usage: jeka build [options] file ..." end def cmd(files, options) if not files.length == 1 puts "ERROR: invalid number of files..." return end if not Jeka::Console::add_algorithms(files[0]) puts "ERROR: No such file or directory..." return end case options[:command] when :build build(options) when :run run(options) end end def build(options) Jeka::Console::build end def run(options) Jeka::Console::run(options[:n]) end def help() puts "Usage: jeka run|build [options] file..." end begin if ARGV.length >= 2 files = [] case ARGV[0] when "build" options[:command] = :build files = build_optparse.parse!(ARGV[1..-1]) when "run" options[:command] = :run files = run_optparse.parse!(ARGV[1..-1]) else help() end cmd(files, options) else help() end rescue OptionParser::MissingArgument puts "ERROR: missing arguments..." rescue OptionParser::InvalidOption puts "ERROR: invalid arguments..." end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jeka-0.2.1 | bin/jeka |