aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib
diff options
context:
space:
mode:
authorMarkus Reiter2017-03-08 19:34:24 +0100
committerGitHub2017-03-08 19:34:24 +0100
commit6ec55a93eb03e5ba682fb4f4d67728e7d79ac550 (patch)
tree82b58d2d4d431f92157094a1d315b02e6c2041df /Library/Homebrew/cask/lib
parent1675f1c95e397c9176db064fb2fccec96a1f86b8 (diff)
parentb24dc2268ade6356e28d912c715c33f12727ef98 (diff)
downloadbrew-6ec55a93eb03e5ba682fb4f4d67728e7d79ac550.tar.bz2
Merge pull request #2293 from reitermarkus/cask-version
Move `brew cask --version` into separate file.
Diffstat (limited to 'Library/Homebrew/cask/lib')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli.rb21
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/--version.rb18
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