Class: Uniword::SpellcheckCLI
- Inherits:
-
Thor
- Object
- Thor
- Uniword::SpellcheckCLI
- Includes:
- CLIHelpers
- Defined in:
- lib/uniword/cli/spellcheck_cli.rb
Overview
Spellcheck subcommands for Uniword CLI.
Provides commands for spell and grammar checking documents:
-
check: run spell and grammar checks on a document
Instance Method Summary collapse
Methods included from CLIHelpers
Instance Method Details
#check(path) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/uniword/cli/spellcheck_cli.rb', line 36 def check(path) doc = load_document(path) say "Spell checking #{path}...", :green checker = Spellcheck::SpellChecker.new( language: [:language], dictionary: [:dictionary], ) result = checker.check(doc) if [:json] puts result.to_json else display_text_report(result) end exit result.clean? ? 0 : 1 rescue Uniword::DependencyError => e say "Error: #{e.}", :red say "Install hunspell: brew install hunspell " \ "(macOS) or apt install hunspell (Ubuntu)", :yellow exit 1 rescue Uniword::Error => e handle_error(e) rescue StandardError => e handle_error(e) end |