aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2014-03-15 12:55:14 -0500
committerJack Nagel2014-03-15 12:55:14 -0500
commit30b4961dde355b03fc9d53f494c7a9a8910df333 (patch)
treea7ffa17e1b7251af3ec76bf677815be6f716a1b4
parente236901e56addff6c887db15c7db47360e463359 (diff)
downloadbrew-30b4961dde355b03fc9d53f494c7a9a8910df333.tar.bz2
Modernize `brew diy`
-rw-r--r--Library/Contributions/manpages/brew.1.md7
-rw-r--r--Library/Homebrew/cmd/diy.rb26
-rw-r--r--share/man/man1/brew.14
3 files changed, 21 insertions, 16 deletions
diff --git a/Library/Contributions/manpages/brew.1.md b/Library/Contributions/manpages/brew.1.md
index 644fe99c9..e27fa8f27 100644
--- a/Library/Contributions/manpages/brew.1.md
+++ b/Library/Contributions/manpages/brew.1.md
@@ -98,14 +98,15 @@ Note that these flags should only appear after a command.
If `--installed` is passed, show dependencies for all installed formulae.
- * `diy [--set-name <name>] [--set-version <version>]`:
+ * `diy [--name=<name>] [--version=<version>]`:
Automatically determine the installation prefix for non-Homebrew software.
Using the output from this command, you can install your own software into
the Cellar and then link it into Homebrew's prefix with `brew link`.
- The options `--set-name` and `--set-version` each take an argument and allow
- you to explicitly set the name and version of the package you are installing.
+ The options `--name=<name>` and `--version=<version>` each take an argument
+ and allow you to explicitly set the name and version of the package you are
+ installing.
* `doctor`:
Check your system for potential problems. Doctor exits with a non-zero status
diff --git a/Library/Homebrew/cmd/diy.rb b/Library/Homebrew/cmd/diy.rb
index 174626afc..fa1822c0e 100644
--- a/Library/Homebrew/cmd/diy.rb
+++ b/Library/Homebrew/cmd/diy.rb
@@ -1,31 +1,35 @@
module Homebrew extend self
def diy
+ %w[name version].each do |opt|
+ if ARGV.include? "--set-#{opt}"
+ opoo "--set-#{opt} is deprecated, please use --#{opt}=<#{opt}> instead"
+ end
+ end
+
path = Pathname.getwd
- version = if ARGV.include? '--set-version'
+ version = ARGV.value "version"
+ version ||= if ARGV.include? "--set-version"
ARGV.next
elsif path.version.to_s.empty?
- raise "Couldn't determine version, try --set-version"
+ raise "Couldn't determine version, set it with --version=<version>"
else
path.version
end
- name = if ARGV.include? '--set-name'
+ name = ARGV.value "name"
+ name ||= if ARGV.include? "--set-name"
ARGV.next
else
- path.basename.to_s =~ /(.*?)-?#{version}/
- if $1.to_s.empty?
- path.basename
- else
- $1
- end
+ basename = path.basename.to_s
+ basename[/(.*?)-?#{Regexp.escape(version)}/, 1] || basename
end
prefix = HOMEBREW_CELLAR/name/version
- if File.file? 'CMakeLists.txt'
+ if File.file? "CMakeLists.txt"
puts "-DCMAKE_INSTALL_PREFIX=#{prefix}"
- elsif File.file? 'Makefile.am'
+ elsif File.file? "Makefile.am"
puts "--prefix=#{prefix}"
else
raise "Couldn't determine build system"
diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1
index d93344669..f0fa7736f 100644
--- a/share/man/man1/brew.1
+++ b/share/man/man1/brew.1
@@ -110,14 +110,14 @@ If \fB\-\-all\fR is passed, show dependencies for all formulae\.
If \fB\-\-installed\fR is passed, show dependencies for all installed formulae\.
.
.TP
-\fBdiy [\-\-set\-name <name>] [\-\-set\-version <version>]\fR
+\fBdiy [\-\-name=<name>] [\-\-version=<version>]\fR
Automatically determine the installation prefix for non\-Homebrew software\.
.
.IP
Using the output from this command, you can install your own software into the Cellar and then link it into Homebrew\'s prefix with \fBbrew link\fR\.
.
.IP
-The options \fB\-\-set\-name\fR and \fB\-\-set\-version\fR each take an argument and allow you to explicitly set the name and version of the package you are installing\.
+The options \fB\-\-name=<name>\fR and \fB\-\-version=<version>\fR each take an argument and allow you to explicitly set the name and version of the package you are installing\.
.
.TP
\fBdoctor\fR