diff --git a/lib/imbecile/cli.rb b/lib/imbecile/cli.rb index 752eaf4..444f9f1 100644 --- a/lib/imbecile/cli.rb +++ b/lib/imbecile/cli.rb @@ -1,10 +1,41 @@ module Imbecile module CLI + USAGE = < +Options: + --version Show program version and exit + -h, --help Show this usage and exit +EOF + class << self def run(args) - p args + input_file = nil + args.each do |arg| + case arg + when "--version" + puts "imbecile v#{VERSION}" + return 0 + when "-h", "--help" + puts USAGE + return 0 + when /^-/ + $stderr.puts "Error: unknown option #{arg}" + return 1 + else + if input_file + $stderr.puts "Error: only one input file supported" + return 1 + else + input_file = arg + end + end + end + if input_file.nil? + $stderr.puts "Error: must specify input file" + return 1 + end end end