diff --git a/Library/Contributions/manpages/brew.1.md b/Library/Contributions/manpages/brew.1.md index 644fe99c98..e27fa8f275 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 ] [--set-version ]`: + * `diy [--name=] [--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=` and `--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 174626afcc..fa1822c0e0 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=" 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 d933446691..f0fa7736f5 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 ] [\-\-set\-version ]\fR +\fBdiy [\-\-name=] [\-\-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=\fR and \fB\-\-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