Merge pull request #4004 from MikeMcQuaid/usability
Address some usability issues.
This commit is contained in:
commit
07997d41e8
@ -1,7 +1,7 @@
|
|||||||
HOMEBREW_HELP = <<~EOS.freeze
|
HOMEBREW_HELP = <<~EOS.freeze
|
||||||
Example usage:
|
Example usage:
|
||||||
brew search [TEXT|/REGEX/]
|
brew search [TEXT|/REGEX/]
|
||||||
brew (info|home|options) [FORMULA...]
|
brew info [FORMULA...]
|
||||||
brew install FORMULA...
|
brew install FORMULA...
|
||||||
brew update
|
brew update
|
||||||
brew upgrade [FORMULA...]
|
brew upgrade [FORMULA...]
|
||||||
@ -11,17 +11,17 @@ HOMEBREW_HELP = <<~EOS.freeze
|
|||||||
Troubleshooting:
|
Troubleshooting:
|
||||||
brew config
|
brew config
|
||||||
brew doctor
|
brew doctor
|
||||||
brew install -vd FORMULA
|
brew install --verbose --debug FORMULA
|
||||||
|
|
||||||
Developers:
|
Contributing:
|
||||||
brew create [URL [--no-fetch]]
|
brew create [URL [--no-fetch]]
|
||||||
brew edit [FORMULA...]
|
brew edit [FORMULA...]
|
||||||
https://docs.brew.sh/Formula-Cookbook
|
|
||||||
|
|
||||||
Further help:
|
Further help:
|
||||||
man brew
|
brew commands
|
||||||
brew help [COMMAND]
|
brew help [COMMAND]
|
||||||
brew home
|
man brew
|
||||||
|
https://docs.brew.sh
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
# NOTE Keep the lenth of vanilla --help less than 25 lines!
|
# NOTE Keep the lenth of vanilla --help less than 25 lines!
|
||||||
|
@ -166,7 +166,8 @@ module Homebrew
|
|||||||
formulae << f
|
formulae << f
|
||||||
else
|
else
|
||||||
opoo <<~EOS
|
opoo <<~EOS
|
||||||
#{f.full_name} #{f.pkg_version} is already installed
|
#{f.full_name} #{f.pkg_version} is already installed and up-to-date
|
||||||
|
To reinstall #{f.pkg_version}, run `brew reinstall #{f.name}`
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
elsif (ARGV.build_head? && new_head_installed) || prefix_installed
|
elsif (ARGV.build_head? && new_head_installed) || prefix_installed
|
||||||
@ -190,12 +191,17 @@ module Homebrew
|
|||||||
EOS
|
EOS
|
||||||
elsif !f.linked? || f.keg_only?
|
elsif !f.linked? || f.keg_only?
|
||||||
msg = <<~EOS
|
msg = <<~EOS
|
||||||
#{msg}, it's just not linked.
|
#{msg}, it's just not linked
|
||||||
You can use `brew link #{f}` to link this version.
|
You can use `brew link #{f}` to link this version.
|
||||||
EOS
|
EOS
|
||||||
elsif ARGV.only_deps?
|
elsif ARGV.only_deps?
|
||||||
msg = nil
|
msg = nil
|
||||||
formulae << f
|
formulae << f
|
||||||
|
else
|
||||||
|
msg = <<~EOS
|
||||||
|
#{msg} and up-to-date
|
||||||
|
To reinstall #{f.pkg_version}, run `brew reinstall #{f.name}`
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
opoo msg if msg
|
opoo msg if msg
|
||||||
elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first
|
elsif !f.any_version_installed? && old_formula = f.old_installed_formulae.first
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#: * `switch` <name> <version>:
|
#: * `switch` <formula> <version>:
|
||||||
#: Symlink all of the specific <version> of <name>'s install to Homebrew prefix.
|
#: Symlink all of the specific <version> of <formula>'s install to Homebrew prefix.
|
||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
require "keg"
|
require "keg"
|
||||||
@ -9,14 +9,15 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def switch
|
def switch
|
||||||
if ARGV.named.length != 2
|
name = ARGV.first
|
||||||
onoe "Usage: brew switch <name> <version>"
|
|
||||||
|
usage = "Usage: brew switch <formula> <version>"
|
||||||
|
|
||||||
|
unless name
|
||||||
|
onoe usage
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
name = ARGV.shift
|
|
||||||
version = ARGV.shift
|
|
||||||
|
|
||||||
rack = Formulary.to_rack(name)
|
rack = Formulary.to_rack(name)
|
||||||
|
|
||||||
unless rack.directory?
|
unless rack.directory?
|
||||||
@ -24,13 +25,21 @@ module Homebrew
|
|||||||
exit 2
|
exit 2
|
||||||
end
|
end
|
||||||
|
|
||||||
# Does the target version exist?
|
versions = rack.subdirs
|
||||||
|
.map { |d| Keg.new(d).version }
|
||||||
|
.sort
|
||||||
|
.join(", ")
|
||||||
|
version = ARGV[1]
|
||||||
|
|
||||||
|
if !version || ARGV.named.length > 2
|
||||||
|
onoe usage
|
||||||
|
puts "#{name} installed versions: #{versions}"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
unless (rack/version).directory?
|
unless (rack/version).directory?
|
||||||
onoe "#{name} does not have a version \"#{version}\" in the Cellar."
|
onoe "#{name} does not have a version \"#{version}\" in the Cellar."
|
||||||
|
puts "#{name} installed versions: #{versions}"
|
||||||
versions = rack.subdirs.map { |d| Keg.new(d).version }.sort
|
|
||||||
puts "Versions available: #{versions.join(", ")}"
|
|
||||||
|
|
||||||
exit 3
|
exit 3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -67,7 +67,14 @@ module Homebrew
|
|||||||
oh1 "No packages to upgrade"
|
oh1 "No packages to upgrade"
|
||||||
else
|
else
|
||||||
oh1 "Upgrading #{Formatter.pluralize(formulae_to_install.length, "outdated package")}, with result:"
|
oh1 "Upgrading #{Formatter.pluralize(formulae_to_install.length, "outdated package")}, with result:"
|
||||||
puts formulae_to_install.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", "
|
formulae_upgrades = formulae_to_install.map do |f|
|
||||||
|
if f.optlinked?
|
||||||
|
"#{f.full_specified_name} #{Keg.new(f.opt_prefix).version} -> #{f.pkg_version}"
|
||||||
|
else
|
||||||
|
"#{f.full_specified_name} #{f.pkg_version}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
puts formulae_upgrades.join(", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sort keg_only before non-keg_only formulae to avoid any needless conflicts
|
# Sort keg_only before non-keg_only formulae to avoid any needless conflicts
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
describe "brew switch", :integration_test do
|
describe "brew switch", :integration_test do
|
||||||
it "allows switching between Formula versions" do
|
it "allows switching between Formula versions" do
|
||||||
expect { brew "switch" }
|
expect { brew "switch" }
|
||||||
.to output(/Usage: brew switch <name> <version>/).to_stderr
|
.to output(/Usage: brew switch <formula> <version>/).to_stderr
|
||||||
.and not_to_output.to_stdout
|
.and not_to_output.to_stdout
|
||||||
.and be_a_failure
|
.and be_a_failure
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ describe "brew switch", :integration_test do
|
|||||||
.and be_a_success
|
.and be_a_success
|
||||||
|
|
||||||
expect { brew "switch", "testball", "0.3" }
|
expect { brew "switch", "testball", "0.3" }
|
||||||
.to output("Versions available: 0.1, 0.2\n").to_stdout
|
.to output("testball installed versions: 0.1, 0.2\n").to_stdout
|
||||||
.and output(/testball does not have a version "0.3"/).to_stderr
|
.and output(/testball does not have a version "0.3"/).to_stderr
|
||||||
.and be_a_failure
|
.and be_a_failure
|
||||||
end
|
end
|
||||||
|
@ -444,8 +444,8 @@ With `--verbose` or `-v`, many commands print extra debugging information. Note
|
|||||||
|
|
||||||
Exits with a non-zero status if any style violations are found.
|
Exits with a non-zero status if any style violations are found.
|
||||||
|
|
||||||
* `switch` `name` `version`:
|
* `switch` `formula` `version`:
|
||||||
Symlink all of the specific `version` of `name`'s install to Homebrew prefix.
|
Symlink all of the specific `version` of `formula`'s install to Homebrew prefix.
|
||||||
|
|
||||||
* `tap`:
|
* `tap`:
|
||||||
List all installed taps.
|
List all installed taps.
|
||||||
|
@ -455,8 +455,8 @@ Passing \fB\-\-only\-cops=\fR\fIcops\fR will check for violations of only the li
|
|||||||
Exits with a non\-zero status if any style violations are found\.
|
Exits with a non\-zero status if any style violations are found\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBswitch\fR \fIname\fR \fIversion\fR
|
\fBswitch\fR \fIformula\fR \fIversion\fR
|
||||||
Symlink all of the specific \fIversion\fR of \fIname\fR\'s install to Homebrew prefix\.
|
Symlink all of the specific \fIversion\fR of \fIformula\fR\'s install to Homebrew prefix\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBtap\fR
|
\fBtap\fR
|
||||||
|
Loading…
x
Reference in New Issue
Block a user