homebrew-cask-versions/lib/cask/cli/base.rb
Claudia 0fe558b927 User-friendly error messages for invalid options/arguments; fixes #5997
- Show a more user-friendly error message when dealing with an option whose (mandatory) argument is missing.

- Likewise, we show a more user-friendly error message when a given option is ambiguous. Examples:
    - Given `-f`, the parser successfully expands to `--fontdir`.

    - Given `-c`, we fail to expand because the parser can’t tell if the user means `--caskroom` or rather `--colorpickerdir`. This exception now results in a nicer error message.

- Some commands now result in a consistent error message when a required cask name is missing.
This affects all stable commands which require one or more cask names as arguments, i. e. `cat`, `create`, `edit`, `fetch`, `info`, `install`, `uninstall`, and `zap`.

- Up to now, the commands `cat`, `create`, `edit`, and `info` used to treat any unknown option as a cask name. This commit changes that behaviour to make it consistent to the rest of the commands (like `fetch`, `install`, `uninstall`, and `zap`), who have silently discarded any unknown option in the past, and continue to do so.
2014-10-05 18:32:33 +02:00

17 lines
344 B
Ruby

class Cask::CLI::Base
def self.command_name
@command_name ||= self.name.sub(%r{^.*:}, '').gsub(%r{(.)([A-Z])}, '\1_\2').downcase
end
def self.visible
true
end
def self.cask_names_from(args)
args.reject { |a| a.chars.first == '-' }
end
def self.help
"No help available for the #{command_name} command"
end
end