diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/create.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Library/Homebrew/cmd/create.rb b/Library/Homebrew/cmd/create.rb index 791ff23d9..a7aa78e49 100644 --- a/Library/Homebrew/cmd/create.rb +++ b/Library/Homebrew/cmd/create.rb @@ -1,4 +1,4 @@ -#: * `create` <URL> [`--autotools`|`--cmake`] [`--no-fetch`] [`--set-name` <name>] [`--set-version` <version>]: +#: * `create` <URL> [`--autotools`|`--cmake`] [`--no-fetch`] [`--set-name` <name>] [`--set-version` <version>] [`--tap` <user>`/`<repo>]: #: Generate a formula for the downloadable file at <URL> and open it in the editor. #: Homebrew will attempt to automatically derive the formula name #: and version, but if it fails, you'll have to make your own template. The `wget` @@ -14,6 +14,9 @@ #: #: 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 creating. +#: +#: The option `--tap` takes a tap as its argument and generates the formula in +#: the specified tap. require "formula" require "blacklist" @@ -41,10 +44,13 @@ module Homebrew version = ARGV.next if ARGV.include? "--set-version" name = ARGV.next if ARGV.include? "--set-name" + tap = ARGV.next if ARGV.include? "--tap" fc = FormulaCreator.new fc.name = name fc.version = version + fc.tap = Tap.fetch(tap || "homebrew/core") + raise TapUnavailableError, tap unless fc.tap.installed? fc.url = url fc.mode = if ARGV.include? "--cmake" @@ -57,7 +63,7 @@ module Homebrew stem = Pathname.new(url).stem print "Formula name [#{stem}]: " fc.name = __gets || stem - fc.path = Formulary.path(fc.name) + fc.update_path end # Don't allow blacklisted formula, or names that shadow aliases, @@ -91,7 +97,7 @@ end class FormulaCreator attr_reader :url, :sha256 - attr_accessor :name, :version, :path, :mode + attr_accessor :name, :version, :tap, :path, :mode def url=(url) @url = url @@ -107,10 +113,8 @@ class FormulaCreator /(.*?)[-_.]?#{path.version}/.match path.basename @name = $1 end - @path = Formulary.path @name unless @name.nil? - else - @path = Formulary.path name end + update_path if @version @version = Version.new(@version) else @@ -118,6 +122,11 @@ class FormulaCreator end end + def update_path + return if @name.nil? || @tap.nil? + @path = Formulary.path "#{@tap}/#{@name}" + end + def fetch? !head? && !ARGV.include?("--no-fetch") end |
