Sha256: 3782063f1952f6089b6f4209f913d5ac2426c4a22b209318ab1980527c7f6aef
Contents?: true
Size: 1.32 KB
Versions: 4
Compression:
Stored size: 1.32 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], [ '--hide-commons', '-H', GetoptLong::NO_ARGUMENT] ) output = 'text' words = -1 hide_commons = 0 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' when '--hide-commons' hide_commons = 1 end end rescue exit 0 end if ARGV.length != 1 raise "Please provide a filename." exit 0 end if hide_commons hide_list = ['or', 'the', 'of', 'a', 'if', 'to', 'and', 'in', 'is', 'are'] else hide_list = [] end w = Wc.new(ARGV[0], words, hide_list) 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
wc-0.94.2 | bin/wc |
wc-0.94.1 | bin/wc |
wc-0.94.0 | bin/wc |
wc-0.93.0 | bin/wc |