The script was lacking structure and had grown a number of one-off hacks
that would be better as reusable functions. So,
- give each subcommand that has completions it's own function
- move completion of formulae, installed brews, and outdated brews into
reusable functions
- introduce a general __brewcomp() function that takes a string of tab,
space, and/or newline separated items and converts all seperators to
newlines, and then generates a reply with compgen().
These changes should allow for easier addition of new features in the
future.
As a bonus, completion for `brew log` will include git-log options if
the git completion script is also loaded.
_brew_to_completion() is kept around for compatiblity.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This will be useful for shell tab completion when something like `brew
install <formula> --version <version>` is implemented.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
We make the assumption that the first non-option word is the command
being invoked.
Originally I was trying to allow command completion for non-standard
command lines like
$ brew --verbose inst<TAB>
but right now executing something like that doesn't actually work. Which
is interesting, because the man page implies that it should. Either the
man page is incorrect, or something was broken between then and now.
Anyway, it would probably be safe to just assume that COMP_WORDS[1] is
the command, and we do make that assumption in other places. But if we
ever do allow things like "brew --option command", this will be useful.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
It is often useful to be reminded that you are, in fact, in the middle
of a debug or interactive install. We provided this reminder in the form
of HOMEBREW_DEBUG_INSTALL, but we can make this even easier for the end
user to consume by exposing it in the form of a shell function.
When HOMEBREW_DEBUG_INSTALL is set, the __brew_ps1() function returns
the string "(formula_name|DEBUG)" by default (much like the __git_ps1()
output when performing some long-running operation, e.g.
"(branch|REBASE-i)". The formatting around "formula_name|DEBUG" can be
customized by passing a format string to the function.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
We already have option completion for `brew install`; now we have it for
all core commands, and the --cache, --cellar, and --prefix flags now
have appropriate formula completion.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Selection of generic installation options, such as `--HEAD`, is now lumped
together with selection of formulae-specific options.
This allows any installation option to be tab-completed *before or after* the
formula name is specified.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
If a formula is given, it will be checked for missing deps.
The formula does not have to be installed first.
Without a formula list, still checks all installed brews.
i.e. `--force --debug --use-llvm --ignore-dependencies --HEAD`
Additionally:
* Use a cleaner `if` block in install options completion case.
* De-dupe options for subsequent completion (e.g. stop offering --foo once
--foo option has been used).
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Since Homebrew's Library doesn't have to be linked under prefix,
we need to do some extra work in the bash completion script to
support this configuration.
Added a "--repository" option to brew, and updated the completion
script to use paths relative to this location.
This is because I have observed two people confuse make with the "make" tool
and thus assume `brew make' is `brew install'.
`brew make' will be deprecated at 0.7, until then it shows a warning.
Large refactor to Formula, mostly improving reliability and error handling but
also layout and readability.
General improvements so testing can be more complete.
Patches are automatically downloaded and applied for Formula that return a
list of urls from Formula::patches.
Split out the brew command logic to facilitate testing.
Facility from Adam Vandenberg to allow selective cleaning of files, added
because Python doesn't work when stripped.