Module: JLPT::CLI

Defined in:
lib/jlpt/cli.rb

Overview

Command Line Interface runner for JLPT gem.

Constant Summary collapse

VALID_COMMANDS =
%w[analyze furigana export batch kanji conjugate simplify stats].freeze

Class Method Summary collapse

Class Method Details

.run(args = ARGV) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jlpt/cli.rb', line 12

def run(args = ARGV)
  options = { format: :text, target_level: :n4 }
  parser = build_option_parser(options)
  parser.parse!(args)
  return 0 if options[:exit_early]

  command = args.shift || 'analyze'
  return warn_unknown(command) unless VALID_COMMANDS.include?(command.to_s.downcase)

  execute_command(command, read_input(args), options)
end