mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-18 06:06:50 -06:00
- 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.
39 lines
861 B
Ruby
39 lines
861 B
Ruby
class Cask::CLI::Create < Cask::CLI::Base
|
|
def self.run(*args)
|
|
cask_names = cask_names_from(args)
|
|
raise CaskUnspecifiedError if cask_names.empty?
|
|
cask_name = cask_names.first.sub(/\.rb$/i,'')
|
|
cask_path = Cask.path(cask_name)
|
|
odebug "Creating Cask #{cask_name}"
|
|
|
|
if cask_path.exist?
|
|
raise CaskAlreadyCreatedError.new cask_name
|
|
end
|
|
|
|
File.open(cask_path, 'w') do |f|
|
|
f.write template(cask_name)
|
|
end
|
|
|
|
exec_editor cask_path
|
|
end
|
|
|
|
def self.template(cask_name);
|
|
cask_class = cask_name.split('-').map(&:capitalize).join
|
|
<<-EOS.undent
|
|
class #{cask_class} < Cask
|
|
version ''
|
|
sha256 ''
|
|
|
|
url 'https://'
|
|
homepage ''
|
|
license :unknown
|
|
|
|
app ''
|
|
end
|
|
EOS
|
|
end
|
|
|
|
def self.help
|
|
"creates a cask of the given name and opens it in an editor"
|
|
end
|
|
end
|