Remove deprecated options from brew-diy

This commit is contained in:
Jack Nagel 2014-07-17 12:24:03 -05:00
parent 8df33f7446
commit ecc9407fed

View File

@ -2,26 +2,10 @@ require "formula"
module Homebrew module Homebrew
def diy 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 path = Pathname.getwd
version = ARGV.value "version" version = ARGV.value("version") || detect_version(path)
version ||= if ARGV.include? "--set-version" name = ARGV.value("name") || detect_name(path, version)
ARGV.next
elsif path.version.to_s.empty?
raise "Couldn't determine version, set it with --version=<version>"
else
path.version
end
name = ARGV.value "name"
name ||= ARGV.next if ARGV.include? "--set-name"
name ||= detected_name(path, version)
prefix = HOMEBREW_CELLAR/name/version prefix = HOMEBREW_CELLAR/name/version
@ -34,7 +18,17 @@ module Homebrew
end end
end end
def detected_name(path, version) def detect_version(path)
version = path.version.to_s
if version.empty?
raise "Couldn't determine version, set it with --version=<version>"
else
version
end
end
def detect_name(path, version)
basename = path.basename.to_s basename = path.basename.to_s
detected_name = basename[/(.*?)-?#{Regexp.escape(version)}/, 1] || basename detected_name = basename[/(.*?)-?#{Regexp.escape(version)}/, 1] || basename
canonical_name = Formulary.canonical_name(detected_name) canonical_name = Formulary.canonical_name(detected_name)