aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhiming Wang2016-06-23 23:23:41 -0700
committerMartin Afanasjew2016-06-24 08:23:41 +0200
commitcb711a2d39a9c76d40f43b4fe13564eba3424ea8 (patch)
treeab88e7021897cfd83ffbe1fb752245410ba2089c
parente2e35def359c5c462ca8447ea9b900e0c49d3019 (diff)
downloadbrew-cb711a2d39a9c76d40f43b4fe13564eba3424ea8.tar.bz2
create: add --tap option (#389)
This commit adds a --tap option to the create command such that a user could create a formula in a specified tap instead of the core.
-rw-r--r--Library/Homebrew/cmd/create.rb21
-rw-r--r--share/doc/homebrew/brew.1.html7
-rw-r--r--share/man/man1/brew.15
3 files changed, 24 insertions, 9 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
diff --git a/share/doc/homebrew/brew.1.html b/share/doc/homebrew/brew.1.html
index b103c0091..8489901b8 100644
--- a/share/doc/homebrew/brew.1.html
+++ b/share/doc/homebrew/brew.1.html
@@ -78,7 +78,7 @@ With <code>--include-aliases</code>, the aliases of internal commands will be in
<dt class="flush"><code>config</code></dt><dd><p>Show Homebrew and system configuration useful for debugging. If you file
a bug report, you will likely be asked for this information if you do not
provide it.</p></dd>
-<dt><code>create</code> <var>URL</var> [<code>--autotools</code>|<code>--cmake</code>] [<code>--no-fetch</code>] [<code>--set-name</code> <var>name</var>] [<code>--set-version</code> <var>version</var>]</dt><dd><p>Generate a formula for the downloadable file at <var>URL</var> and open it in the editor.
+<dt><code>create</code> <var>URL</var> [<code>--autotools</code>|<code>--cmake</code>] [<code>--no-fetch</code>] [<code>--set-name</code> <var>name</var>] [<code>--set-version</code> <var>version</var>] [<code>--tap</code> <var>user</var><code>/</code><var>repo</var>]</dt><dd><p>Generate a formula for the downloadable file at <var>URL</var> 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 <code>wget</code>
formula serves as a simple example. For the complete API have a look at</p>
@@ -92,7 +92,10 @@ If <code>--cmake</code> is passed, create a basic template for a CMake-style bui
will thus not add the SHA256 to the formula for you.</p>
<p>The options <code>--set-name</code> and <code>--set-version</code> each take an argument and allow
-you to explicitly set the name and version of the package you are creating.</p></dd>
+you to explicitly set the name and version of the package you are creating.</p>
+
+<p>The option <code>--tap</code> takes a tap as its argument and generates the formula in
+the specified tap.</p></dd>
<dt><code>deps</code> [<code>--1</code>] [<code>-n</code>] [<code>--union</code>] [<code>--installed</code>] [<code>--include-build</code>] [<code>--include-optional</code>] [<code>--skip-recommended</code>] <var>formulae</var></dt><dd><p>Show dependencies for <var>formulae</var>. When given multiple formula arguments,
show the intersection of dependencies for <var>formulae</var>.</p>
diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1
index 54f6ca78b..8aa1144fc 100644
--- a/share/man/man1/brew.1
+++ b/share/man/man1/brew.1
@@ -110,7 +110,7 @@ If \fB\-\-quiet\fR is passed, list only the names of commands without the header
Show Homebrew and system configuration useful for debugging\. If you file a bug report, you will likely be asked for this information if you do not provide it\.
.
.TP
-\fBcreate\fR \fIURL\fR [\fB\-\-autotools\fR|\fB\-\-cmake\fR] [\fB\-\-no\-fetch\fR] [\fB\-\-set\-name\fR \fIname\fR] [\fB\-\-set\-version\fR \fIversion\fR]
+\fBcreate\fR \fIURL\fR [\fB\-\-autotools\fR|\fB\-\-cmake\fR] [\fB\-\-no\-fetch\fR] [\fB\-\-set\-name\fR \fIname\fR] [\fB\-\-set\-version\fR \fIversion\fR] [\fB\-\-tap\fR \fIuser\fR\fB/\fR\fIrepo\fR]
Generate a formula for the downloadable file at \fIURL\fR 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 \fBwget\fR formula serves as a simple example\. For the complete API have a look at
.
.IP
@@ -125,6 +125,9 @@ If \fB\-\-no\-fetch\fR is passed, Homebrew will not download \fIURL\fR to the ca
.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 creating\.
.
+.IP
+The option \fB\-\-tap\fR takes a tap as its argument and generates the formula in the specified tap\.
+.
.TP
\fBdeps\fR [\fB\-\-1\fR] [\fB\-n\fR] [\fB\-\-union\fR] [\fB\-\-installed\fR] [\fB\-\-include\-build\fR] [\fB\-\-include\-optional\fR] [\fB\-\-skip\-recommended\fR] \fIformulae\fR
Show dependencies for \fIformulae\fR\. When given multiple formula arguments, show the intersection of dependencies for \fIformulae\fR\.