Sha256: 52c84578a24d4055de4195bb8e1804723c93ab26ffc045f69432b1e98b7848b2
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
#!/usr/bin/env ruby require "pathname" require "optparse" require_relative "../lib/dead_end" options = {} options[:terminal] = true options[:record_dir] = ENV["DEAD_END_RECORD_DIR"] parser = OptionParser.new do |opts| opts.banner = <<~EOM Usage: dead_end <file> [options] Parses a ruby source file and searches for syntax error(s) such as unexpected `end', expecting end-of-input. Example: $ dead_end dog.rb # ... ❯ 10 defdog ❯ 15 end ❯ 16 Env options: DEAD_END_RECORD_DIR=<dir> When enabled, records the steps used to search for a syntax error to the given directory Options: EOM opts.version = DeadEnd::VERSION opts.on("--help", "Help - displays this message") do |v| puts opts exit end opts.on("--record <dir>", "When enabled, records the steps used to search for a syntax error to the given directory") do |v| options[:record_dir] = v end opts.on("--no-terminal", "Disable terminal highlighting") do |v| options[:terminal] = false end end parser.parse! file = ARGV[0] if file.nil? || file.empty? # Display help if raw command parser.parse! %w[--help] end file = Pathname(file) options[:record_dir] = "tmp" if ENV["DEBUG"] warn "Record dir: #{options[:record_dir]}" if options[:record_dir] display = DeadEnd.call( source: file.read, filename: file.expand_path, terminal: options[:terminal], record_dir: options[:record_dir] ) if display.document_ok? exit(0) else exit(1) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dead_end-2.0.1 | exe/dead_end |