aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/command.rb14
-rw-r--r--Library/Homebrew/global.rb17
-rw-r--r--Library/Homebrew/manpages/brew.1.md3
-rwxr-xr-xLibrary/brew.rb18
4 files changed, 35 insertions, 17 deletions
diff --git a/Library/Homebrew/cmd/command.rb b/Library/Homebrew/cmd/command.rb
new file mode 100644
index 000000000..c2ea96dab
--- /dev/null
+++ b/Library/Homebrew/cmd/command.rb
@@ -0,0 +1,14 @@
+module Homebrew
+ def command
+ cmd = ARGV.first
+ cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
+
+ if (path = HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb"; path.file?)
+ puts path
+ elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb"))
+ puts path
+ else
+ odie "Unknown command: #{cmd}"
+ end
+ end
+end
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index ba79f40d6..d9ec1a265 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -54,3 +54,20 @@ HOMEBREW_PULL_OR_COMMIT_URL_REGEX = %r[https://github\.com/([\w-]+)/homebrew(-[\
require 'compat' unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
ORIGINAL_PATHS = ENV['PATH'].split(File::PATH_SEPARATOR).map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
+
+HOMEBREW_INTERNAL_COMMAND_ALIASES = {
+ 'ls' => 'list',
+ 'homepage' => 'home',
+ '-S' => 'search',
+ 'up' => 'update',
+ 'ln' => 'link',
+ 'instal' => 'install', # gem does the same
+ 'rm' => 'uninstall',
+ 'remove' => 'uninstall',
+ 'configure' => 'diy',
+ 'abv' => 'info',
+ 'dr' => 'doctor',
+ '--repo' => '--repository',
+ 'environment' => '--env',
+ '--config' => 'config',
+}
diff --git a/Library/Homebrew/manpages/brew.1.md b/Library/Homebrew/manpages/brew.1.md
index 909b7448c..273228b4c 100644
--- a/Library/Homebrew/manpages/brew.1.md
+++ b/Library/Homebrew/manpages/brew.1.md
@@ -69,6 +69,9 @@ Note that these flags should only appear after a command.
versions of formula. Note downloads for any installed formula will still not be
deleted. If you want to delete those too: `rm -rf $(brew --cache)`
+ * `command` <cmd>:
+ Display the path to the file which is used when invoking `brew <cmd>`.
+
* `commands`:
Show a list of built-in and external commands.
diff --git a/Library/brew.rb b/Library/brew.rb
index e9c9fe994..abe7f847a 100755
--- a/Library/brew.rb
+++ b/Library/brew.rb
@@ -65,22 +65,6 @@ end
begin
trap("INT", std_trap) # restore default CTRL-C handler
- aliases = {'ls' => 'list',
- 'homepage' => 'home',
- '-S' => 'search',
- 'up' => 'update',
- 'ln' => 'link',
- 'instal' => 'install', # gem does the same
- 'rm' => 'uninstall',
- 'remove' => 'uninstall',
- 'configure' => 'diy',
- 'abv' => 'info',
- 'dr' => 'doctor',
- '--repo' => '--repository',
- 'environment' => '--env',
- '--config' => 'config',
- }
-
empty_argv = ARGV.empty?
help_regex = /(-h$|--help$|--usage$|-\?$|^help$)/
help_flag = false
@@ -96,7 +80,7 @@ begin
end
end
- cmd = aliases[cmd] if aliases[cmd]
+ cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
sudo_check = %w[ install link pin unpin upgrade ]