Class: Forspell::CLI

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

Constant Summary collapse

ERROR_CODE =
2
CONFIG_PATH =
File.join(Dir.pwd, '.forspell')
DEFAULT_CUSTOM_DICT =
File.join(Dir.pwd, 'forspell.dict')
FORMATS =
%w[readable yaml json].freeze
FORMAT_ERR =
"must be one of the following: #{FORMATS.join(', ')}"
DEFINITIONS =
proc do |o|
  o.array '-e', '--exclude-paths', 'List of paths to exclude'
  o.string '-d', '--dictionary-path', 'Path to main hunspell dictionary to use (by default, forspell\'s en_US)', default: 'en_US'
  o.array '-c', '--custom-paths', 'Paths to custom dictionaries', default: []
  o.string '-f', '--format', 'Output formats: readable(default), JSON, YAML', default: 'readable'
  o.bool '--gen-dictionary', 'Generate custom dictionary', default: false
  o.bool '--print-filepaths', 'Enable file paths in dictionary mode', default: false
  o.string '-l', '--logfile', 'Log to specified path'
  o.bool '-v', '--verbose', 'Verbose mode', default: false
  o.bool '--no-suggest', 'Output without suggestions', default: false
  o.integer '--suggestions-size', 'How many suggestions for each error should be returned', default: 3
  o.on '--help' do
    puts o
    exit
  end
end

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CLI

Returns a new instance of CLI.



35
36
37
# File 'lib/forspell/cli.rb', line 35

def initialize options
  @options = options
end

Instance Method Details

#callObject



39
40
41
42
43
44
45
# File 'lib/forspell/cli.rb', line 39

def call
  init_options
  init_reporter
  create_files_list
  init_speller
  run
end