Sha256: 59b8d099fc67810f76c19e41fa8ddcc8a19cfa04df56ab0fa9d3c563a6600083
Contents?: true
Size: 851 Bytes
Versions: 2
Compression:
Stored size: 851 Bytes
Contents
#!/usr/bin/env ruby require 'lib/Wc' require 'getoptlong' require 'rdoc/usage' require 'json' opts = GetoptLong.new( [ '--help', '-h', GetoptLong::NO_ARGUMENT ], [ '--version', '-v', GetoptLong::NO_ARGUMENT ], [ '--json', '-j', GetoptLong::NO_ARGUMENT ], [ '--xml', '-x', GetoptLong::NO_ARGUMENT ] ) output = 'text' begin opts.each do |opt, arg| case opt when '--help' RDoc::usage exit 0 when '--version' @version = File.exist?('VERSION') ? File.read('VERSION') : "" puts @version exit 0 when '--json' output = 'json' end end rescue exit 0 end if ARGV.length != 1 raise "Please provide a filename." exit 0 end w = Wc.new(ARGV[0]) if output == 'text' w.to_text end if output == 'json' w.to_json end if output == 'xml' puts 'xml support is coming soon...' end exit 0
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wc-0.22.0 | bin/wc |
wc-0.21.0 | bin/wc |