Class: Romajic::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/romajic/cli.rb

Overview

Command-line interface of Romajic

Instance Method Summary collapse

Instance Method Details

#search(word = nil) ⇒ Object

Search romaji in the source files

Parameters:

  • word (String) (defaults to: nil)

    Target romaji



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/romajic/cli.rb', line 20

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

#versionObject

Print the version



45
46
47
# File 'lib/romajic/cli.rb', line 45

def version
  puts "romajic #{Romajic::VERSION}"
end