Class: SnippetCli::Commands::Check

Inherits:
Dry::CLI::Command
  • Object
show all
Includes:
WizardHelpers::ErrorHandler, WizardHelpers::MatchFileSelector
Defined in:
lib/snippet_cli/commands/check.rb

Instance Method Summary collapse

Methods included from WizardHelpers::MatchFileSelector

#pick_match_file

Methods included from WizardHelpers::PromptHelpers

#collect_search_terms, #confirm!, #list_confirm!, #optional_prompt, #prompt!

Methods included from WizardHelpers::ErrorHandler

#handle_errors

Instance Method Details

#call(file: nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/snippet_cli/commands/check.rb', line 23

def call(file: nil, **)
  handle_errors(NoMatchFilesError) do
    file ||= pick_match_file.last
    data = YamlLoader.load(file)
    report(file, FileValidator.errors_structured(data))
  end
rescue FileMissingError, InvalidYamlError => e
  warn e.message
  exit 1
end