bin/code in code-ruby-0.9.3 vs bin/code in code-ruby-0.10.0

- old
+ new

@@ -10,68 +10,67 @@ profiler: "text", input: "", parse: false } -argv = OptionParser - .new do |opts| - opts.banner = "Usage: code INPUT\n\n" +argv = + OptionParser + .new do |opts| + opts.banner = "Usage: code INPUT\n\n" - opts.on("-v", "--version", "Version of Code") do |_input| - puts Code::Version - exit - end + opts.on("-v", "--version", "Version of Code") do |_input| + puts Code::Version + exit + end - opts.on( - "-i INPUT", - "--input INPUT", - "Input in the Code language (String or File)" - ) do |input| - input = File.read(input) if File.exist?(input) + opts.on( + "-i INPUT", + "--input INPUT", + "Input in the Code language (String or File)" + ) do |input| + input = File.read(input) if File.exist?(input) - options[:input] = input - end + options[:input] = input + end - opts.on("-p", "--parse", "Parser tree for input") do |parse| - options[:parse] = parse - end + opts.on("-p", "--parse", "Parser tree for input") do |parse| + options[:parse] = parse + end - opts.on( - "-t TIMEOUT", - "--timeout TIMEOUT", - "Set timeout in seconds" - ) { |timeout| options[:timeout] = timeout.to_f } + opts.on( + "-t TIMEOUT", + "--timeout TIMEOUT", + "Set timeout in seconds" + ) { |timeout| options[:timeout] = timeout.to_f } - opts.on("--profile", "Profile Ruby code") do |_timeout| - require "ruby-prof" - options[:profile] = true - end + opts.on("--profile", "Profile Ruby code") do |_timeout| + require "ruby-prof" + options[:profile] = true + end - opts.on( - "--profiler TYPE", - "Profiler output type (text (default) or html)" - ) do |profiler| - require "ruby-prof" - options[:profile] = true - options[:profiler] = profiler + opts.on( + "--profiler TYPE", + "Profiler output type (text (default) or html)" + ) do |profiler| + require "ruby-prof" + options[:profile] = true + options[:profiler] = profiler + end end - end - .parse! + .parse! options[:input] = argv.join(" ") if options[:input].empty? -if options[:input].empty? - abort <<~HELP - Usage: code INPUT +abort <<~HELP if options[:input].empty? + Usage: code INPUT - -v, --version Version of Code - -i, --input INPUT Input in the Code language (String or File) - -p, --parse Parser tree for input - -t, --timeout TIMEOUT Set timeout in seconds - --profile Profile Ruby code - --profiler TYPE Profiler output type (text (default) or html) - HELP -end + -v, --version Version of Code + -i, --input INPUT Input in the Code language (String or File) + -p, --parse Parser tree for input + -t, --timeout TIMEOUT Set timeout in seconds + --profile Profile Ruby code + --profiler TYPE Profiler output type (text (default) or html) +HELP RubyProf.start if options[:profile] if options[:parse] pp Code::Parser.parse(options[:input]).to_raw