diff options
| author | Markus Reiter | 2017-03-08 15:49:37 +0100 |
|---|---|---|
| committer | Markus Reiter | 2017-03-08 15:49:37 +0100 |
| commit | b24dc2268ade6356e28d912c715c33f12727ef98 (patch) | |
| tree | 8840b9320ef9697a3b19c9fd8f446056684e76bf /Library/Homebrew/cask/lib | |
| parent | ef02414888ec332aa4220fe05428f24b9a4f035f (diff) | |
| download | brew-b24dc2268ade6356e28d912c715c33f12727ef98.tar.bz2 | |
Move `brew cask --version` into separate file.
Diffstat (limited to 'Library/Homebrew/cask/lib')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli.rb | 21 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/--version.rb | 18 |
2 files changed, 28 insertions, 11 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index 3176489cb..27bea06ef 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -19,6 +19,7 @@ require "hbc/cli/reinstall" require "hbc/cli/search" require "hbc/cli/style" require "hbc/cli/uninstall" +require "hbc/cli/--version" require "hbc/cli/zap" require "hbc/cli/internal_use_base" @@ -116,7 +117,7 @@ module Hbc elsif command.to_s.include?("/") && require?(command.to_s) # external command as Ruby library with literal path, useful # for development and troubleshooting - sym = Pathname.new(command.to_s).basename(".rb").to_s.capitalize + sym = File.basename(command.to_s, ".rb").capitalize klass = begin const_get(sym) rescue NameError @@ -247,16 +248,14 @@ module Hbc @attempted_verb = attempted_verb end - def run(*args) - if args.include?("--version") || @attempted_verb == "--version" - puts Hbc.full_version - else - purpose - usage - unless @attempted_verb.to_s.strip.empty? || @attempted_verb == "help" - raise CaskError, "Unknown command: #{@attempted_verb}" - end - end + def run(*_args) + purpose + usage + + return if @attempted_verb.to_s.strip.empty? + return if @attempted_verb == "help" + + raise ArgumentError, "Unknown command: #{@attempted_verb}" end def purpose diff --git a/Library/Homebrew/cask/lib/hbc/cli/--version.rb b/Library/Homebrew/cask/lib/hbc/cli/--version.rb new file mode 100644 index 000000000..bbc719c3b --- /dev/null +++ b/Library/Homebrew/cask/lib/hbc/cli/--version.rb @@ -0,0 +1,18 @@ +module Hbc + class CLI + class Version < Base + def self.command_name + "--#{super}" + end + + def self.run(*args) + raise ArgumentError, "#{command_name} does not take arguments." unless args.empty? + puts Hbc.full_version + end + + def self.help + "displays the Homebrew-Cask version" + end + end + end +end |
