module Dry::CLI::SpellChecker

def self.call(result, arguments)

Other tags:
    Api: - private

Other tags:
    Since: - 1.1.1
def self.call(result, arguments)
  commands = result.children.keys
  cmd = cmd_to_spell(arguments, result.names)
  suggestions = DidYouMean::SpellChecker.new(dictionary: commands).correct(cmd.first)
  if suggestions.any?
    "I don't know how to '#{cmd.join(" ")}'. Did you mean: '#{suggestions.first}' ?"
  end
end

def self.cmd_to_spell(arguments, result_names)

Other tags:
    Api: - private

Other tags:
    Since: - 1.1.1
def self.cmd_to_spell(arguments, result_names)
  arguments - result_names
end

def self.ignore?(cmd)

Other tags:
    Api: - private

Other tags:
    Since: - 1.1.1
def self.ignore?(cmd)
  cmd.empty? || cmd.first.start_with?("-")
end