Sha256: b0ee7183dfd1edf94bccba2f441b00e08789fa6b90de0071dae6f2d9a779d167
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
require 'thor' require 'romajic/cop' # Automatic romaji spelling checker module Romajic # Command-line interface of {Romajic} class CLI < Thor desc 'search WORD', 'Search romaji' option :exclude_word, type: :string, aliases: '-e', banner: 'WORD TO EXCLUDE' option :config, type: :string, aliases: '-c', banner: 'PATH OF THE CONFIGURATION FILE' option :dir, type: :string, aliases: '-d', banner: 'PATH OF TARGET DIRECTORY' option :extensions, type: :string, aliases: '-E', banner: 'COMMA-SEPARATED TARGET EXTENSIONS' option :distance, type: :numeric, aliases: '-D', banner: 'LEVENSHTEIN DISTANCE' option :converter, type: :string, aliases: '-C', banner: 'ROMAJI CONVERTER, e.g. hepburn, modified_hepburn, traditional_hepburn, nihon, or kunrei' # Search romaji in the source files # # @param word [String] Target romaji def search(word = nil) cop_options = {} cop_options[:word] = word if word cop_options[:exclude_word] = options[:exclude_word] if options[:exclude_word] if options[:config] cop_options[:config] = File.expand_path(options[:config]) else cop_options[:config] = File.expand_path('../../../default.yml', __FILE__) end cop_options[:dir] = options[:dir] if options[:dir] cop_options[:extensions] = options[:extensions] if options[:extensions] cop_options[:distance] = options[:distance] if options[:distance] cop_options[:converter] = options[:converter] if options[:converter] cop = Cop.new(cop_options) cop.search end desc '-v, --version', 'Print the version' map %w(-v --version) => :version # Print the version def version puts "romajic #{Romajic::VERSION}" end end CLI.start end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
romajic-0.1.0 | lib/romajic/cli.rb |