Sha256: f731da45844cc2b793293c3c34f45fc33432897978e27bc956be7771c657ebe7
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
#!/usr/bin/env ruby $stdout.sync = true require "bundler/setup" require "superscript" require "optparse" options = { methods: false, on_error_exec: nil } ARGV << "-h" if ARGV.empty? optparse = OptionParser.new do |opt| opt.on('--allow-methods') { |o| options[:methods] = true } opt.on('--on-error-exec CMD') { |o| options[:on_error_exec] = o } end.parse! best_guess_path = if ARGV[0].start_with? "/" ARGV[0] else File.join(".", ARGV[0]) end require best_guess_path ctx_classname = File.basename(ARGV[0]).split(".").first.capitalize ctx = (eval "#{ctx_classname}").new if ARGV[1] runner = Superscript::Runner.new ARGV[1], options runner.run! ctx else require "readline" runner = Superscript::Runner.new nil, options loop do contents = Readline.readline "> ", true next if contents == "" if contents == nil puts "\n-- press ^D to end input" contents = $stdin.readlines.join("\n") end next if contents == "" value = runner.run! ctx, contents: contents puts " => #{value.inspect}" end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
superscript-0.12.0 | exe/superscript |
superscript-0.11.0 | exe/superscript |
superscript-0.10.0 | exe/superscript |
superscript-0.9.0 | exe/superscript |