Sha256: b50e8ac686c5c530544bbc366b6e97ab1f17bdae818d676a18c2f8c7dd3321db
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
#!/usr/bin/env ruby require 'ruby-beautify' require 'ripper' require 'optparse' include RubyBeautify Options = OptionParser.new do |opts| opts.on("-V", "--version", "Print version") { |version| puts RBeautify::VERSION;exit 0} opts.on("-c", "--indent_count [COUNT]", Integer, "Count of characters to use for indenting. (default: 1)") { |count| @indent_count = count} opts.on("-t", "--tabs", "Use tabs for the indent character (default)") { @indent_token = "\t" } opts.on("-s", "--spaces", "Use spaces for the indent character") { @indent_token = " " } opts.banner = "Usage: print ruby into a pretty format, or break trying." end Options.parse! @indent_token = "\t" unless @indent_token @indent_count = 1 unless @indent_count # no argument, assume we want to open STDIN. if ARGV.empty? content = $stdin.read else file = ARGV[0] if File.exist? file content = open(file).read else puts "No such file: #{file}" exit end end if content if syntax_ok? content pretty_string content, indent_token: @indent_token, indent_count: @indent_count else puts content exit 127 end end
Version data entries
2 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-beautify-0.96.0 | bin/rbeautify |
ruby-beautify-0.96.0 | bin/ruby-beautify |