Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help: finish command help move, improve generic help #113

Closed
wants to merge 8 commits into from
6 changes: 6 additions & 0 deletions Library/Homebrew/cmd/--cache.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#: * `--cache`:
#: Display Homebrew's download cache. See also `HOMEBREW_CACHE`.
#:
#: * `--cache` <formula>:
#: Display the file or directory used to cache <formula>.

require "cmd/fetch"

module Homebrew
Expand Down
8 changes: 8 additions & 0 deletions Library/Homebrew/cmd/--cellar.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#: * `--cellar`:
#: Display Homebrew's Cellar path. *Default:* `$(brew --prefix)/Cellar`, or if
#: that directory doesn't exist, `$(brew --repository)/Cellar`.
#:
#: * `--cellar` <formula>:
#: Display the location in the cellar where <formula> would be installed,
#: without any sort of versioned directory as the last path.

module Homebrew
def __cellar
if ARGV.named.empty?
Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/cmd/--env.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#: * `--env`:
#: Show a summary of the Homebrew build environment.

require "extend/ENV"
require "build_environment"

Expand Down
6 changes: 6 additions & 0 deletions Library/Homebrew/cmd/--prefix.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#: * `--prefix`:
#: Display Homebrew's install path. *Default:* `/usr/local`
#:
#: * `--prefix` <formula>:
#: Display the location in the cellar where <formula> is or would be installed.

module Homebrew
def __prefix
if ARGV.named.empty?
Expand Down
7 changes: 7 additions & 0 deletions Library/Homebrew/cmd/--repository.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#: * `--repository`:
#: Display where Homebrew's `.git` directory is located. For standard installs,
#: the `prefix` and `repository` are the same directory.
#:
#: * `--repository` <user>`/`<repo>:
#: Display where tap <user>`/`<repo>'s directory is located.

require "tap"

module Homebrew
Expand Down
12 changes: 12 additions & 0 deletions Library/Homebrew/cmd/--version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#: * `--version`:
#: Print the version number of Homebrew to standard output and exit.

module Homebrew
def __version
# As a special case, `--version` is implemented directly in `brew.rb`. This
# file merely serves as a container for the documentation. It also catches
# the case where running `brew --version` with additional arguments would
# produce a rather cryptic message about a non-existent `--version` command.
raise UsageError
end
end
9 changes: 5 additions & 4 deletions Library/Homebrew/cmd/help.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
HOMEBREW_HELP = <<-EOS
Example usage:
brew [info | home | options ] [FORMULA...]
brew (info|home|options) [FORMULA...]
brew install FORMULA...
brew uninstall FORMULA...
brew search [foo]
brew search [TEXT|/PATTERN/]
brew list [FORMULA...]
brew update
brew upgrade [FORMULA...]
brew pin/unpin [FORMULA...]
brew (pin|unpin) [FORMULA...]

Troubleshooting:
brew doctor
brew install -vd FORMULA
brew [--env | config]
brew (--env|config)

Brewing:
brew create [URL [--no-fetch]]
Expand All @@ -21,6 +21,7 @@

Further help:
man brew
brew help [COMMAND]
brew home
EOS

Expand Down
7 changes: 6 additions & 1 deletion Library/Homebrew/cmd/man.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def build_man_page
variables = OpenStruct.new

variables[:commands] = Pathname.glob("#{HOMEBREW_LIBRARY_PATH}/cmd/*.{rb,sh}").
sort_by { |source_file| source_file.basename.sub(/\.(rb|sh)$/, "") }.
sort_by { |source_file| sort_key_for_path(source_file) }.
map { |source_file|
source_file.read.lines.
grep(/^#:/).
Expand All @@ -56,6 +56,11 @@ def build_man_page
ERB.new(template, nil, ">").result(variables.instance_eval{ binding })
end

def sort_key_for_path(path)
# Options after regular commands (`~` comes after `z` in ASCII table).
path.basename.to_s.sub(/\.(rb|sh)$/, "").sub(/^--/, "~~")
end

def convert_man_page(markup, target)
shared_args = %W[
--pipe
Expand Down
33 changes: 0 additions & 33 deletions Library/Homebrew/manpages/brew.1.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,6 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note

<%= commands.join("\n") %>

* `--cache`:
Display Homebrew's download cache. See also `HOMEBREW_CACHE`.

* `--cache` <formula>:
Display the file or directory used to cache <formula>.

* `--cellar`:
Display Homebrew's Cellar path. *Default:* `$(brew --prefix)/Cellar`, or if
that directory doesn't exist, `$(brew --repository)/Cellar`.

* `--cellar` <formula>:
Display the location in the cellar where <formula> would be installed,
without any sort of versioned directory as the last path.

* `--env`:
Show a summary of the Homebrew build environment.

* `--prefix`:
Display Homebrew's install path. *Default:* `/usr/local`

* `--prefix` <formula>:
Display the location in the cellar where <formula> is or would be installed.

* `--repository`:
Display where Homebrew's `.git` directory is located. For standard installs,
the `prefix` and `repository` are the same directory.

* `--repository` <user>`/`<repo>:
Display where tap <user>`/`<repo>'s directory is located.

* `--version`:
Print the version number of brew to standard error and exit.

## EXTERNAL COMMANDS

Homebrew, like `git`(1), supports external commands. These are executable
Expand Down
2 changes: 1 addition & 1 deletion share/doc/homebrew/brew.1.html
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ <h2 id="COMMANDS">COMMANDS</h2>
<dt><code>--repository</code></dt><dd><p>Display where Homebrew's <code>.git</code> directory is located. For standard installs,
the <code>prefix</code> and <code>repository</code> are the same directory.</p></dd>
<dt><code>--repository</code> <var>user</var><code>/</code><var>repo</var></dt><dd><p>Display where tap <var>user</var><code>/</code><var>repo</var>'s directory is located.</p></dd>
<dt><code>--version</code></dt><dd><p>Print the version number of brew to standard error and exit.</p></dd>
<dt><code>--version</code></dt><dd><p>Print the version number of Homebrew to standard output and exit.</p></dd>
</dl>


Expand Down
2 changes: 1 addition & 1 deletion share/man/man1/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ Display where tap \fIuser\fR\fB/\fR\fIrepo\fR\'s directory is located\.
.
.TP
\fB\-\-version\fR
Print the version number of brew to standard error and exit\.
Print the version number of Homebrew to standard output and exit\.
.
.SH "EXTERNAL COMMANDS"
Homebrew, like \fBgit\fR(1), supports external commands\. These are executable scripts that reside somewhere in the \fBPATH\fR, named \fBbrew\-\fR\fIcmdname\fR or \fBbrew\-\fR\fIcmdname\fR\fB\.rb\fR, which can be invoked like \fBbrew\fR \fIcmdname\fR\. This allows you to create your own commands without modifying Homebrew\'s internals\.
Expand Down