Sha256: ab31b7ba4f5cf4243faf4187727865b8f608ab3d135ee33612784c7a1c2e04a0
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
#!/usr/bin/env ruby require 'lib/Wc' require 'getoptlong' require 'rdoc/usage' require 'json' opts = GetoptLong.new( [ '--help', '-h', GetoptLong::NO_ARGUMENT ], [ '--words', '-w', GetoptLong::REQUIRED_ARGUMENT], [ '--version', '-v', GetoptLong::NO_ARGUMENT ], [ '--json', '-j', GetoptLong::NO_ARGUMENT ], [ '--xml', '-x', GetoptLong::NO_ARGUMENT ], [ '--cloud', '-c', GetoptLong::NO_ARGUMENT] ) output = 'text' words = -1 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' when '--words' words = arg.to_i when '--cloud' output = 'cloud' end end rescue exit 0 end if ARGV.length != 1 raise "Please provide a filename." exit 0 end w = Wc.new(ARGV[0], words) if output == 'text' w.to_text end if output == 'json' p w.to_json end if output == 'xml' puts 'xml support is coming soon...' end if output == 'cloud' puts w.to_cloud end exit 0
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wc-0.92.0 | bin/wc |