Sha256: 590cf462c4ef6befbe264640238103579bd0a9ce204fd247ad89035e2e90aa7f
Contents?: true
Size: 1.38 KB
Versions: 6
Compression:
Stored size: 1.38 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 options = {"hide_list" => hide_list, "words"=>words} w = Wc.new(ARGV[0], options ) 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
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
wc-0.99.0 | bin/wc |
wc-0.98.2 | bin/wc |
wc-0.98.1 | bin/wc |
wc-0.98.0 | bin/wc |
wc-0.97.0 | bin/wc |
wc-0.96.0 | bin/wc |