Sha256: 70d006ced78de282e01536385d42c870ba9b398ba3645d0ffcccaec13151eb9c
Contents?: true
Size: 983 Bytes
Versions: 3
Compression:
Stored size: 983 Bytes
Contents
require "optparse" module Charwidth class CLI def self.run(argv) new.run(argv) end def run(argv) options = {} optparse = OptionParser.new do |o| o.banner += " TEXT\nNormalize character width in arguments or STDIN.\nAvailable character types are #{Charwidth::ClassMethods::TYPES.join(",")}." o.on("--only=TYPES", "Comma separated character types that should be converted"){|types| options[:only] = types.split(",").map(&:to_sym) } o.on("--except=TYPES", "Comma separated character types that should not be converted"){|types| options[:except] = types.split(",").map(&:to_sym) } o.parse!(argv) end src = nil if ARGV.empty? if STDIN.tty? STDERR.puts optparse.banner STDERR.puts optparse.help exit 1 else src = STDIN.read end else src = ARGV.join(" ") end print Charwidth.normalize(src, options) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
charwidth-0.1.5 | lib/charwidth/cli.rb |
charwidth-0.1.4 | lib/charwidth/cli.rb |
charwidth-0.1.3 | lib/charwidth/cli.rb |