aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMax Howell2009-09-28 17:01:44 +0100
committerMax Howell2009-09-29 15:46:34 +0100
commit6fdb6c1deda060128ae4bd3d8020e5982a30d358 (patch)
tree0c38296e2d782119ddffb58ec3b227446247a472 /Library/Homebrew
parent25fb9e496e911657ed8194a88ac1bac306fcbd6c (diff)
downloadhomebrew-6fdb6c1deda060128ae4bd3d8020e5982a30d358.tar.bz2
If brew create can't figure out the name, prompt for it
This was adapted from adamv@d5e78ee26535dec4b11c33d14832a9ee945a29fd I decided prompting would was the most usable solution here, as the stem is unlikely to be useful so the user would have to rename the file and change the class name as well as type the command once and then again with --force. Dissent welcome. Fixes #15
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/brew.h.rb32
1 files changed, 24 insertions, 8 deletions
diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb
index a30a82b80..6ddee7721 100644
--- a/Library/Homebrew/brew.h.rb
+++ b/Library/Homebrew/brew.h.rb
@@ -21,21 +21,16 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-def make url
+def __make url, name
require 'formula'
- path=Pathname.new url
-
- /(.*?)[-_.]?#{path.version}/.match path.basename
- raise "Couldn't parse name from #{url}" if $1.nil? or $1.empty?
-
- path=Formula.path $1
+ path = Formula.path name
raise "#{path} already exists" if path.exist?
template=<<-EOS
require 'brewkit'
- class #{Formula.class_s $1} <Formula
+ class #{Formula.class_s name} <Formula
url '#{url}'
homepage ''
md5 ''
@@ -89,6 +84,27 @@ def make url
end
+def make url
+ path = Pathname.new url
+
+ /(.*?)[-_.]?#{path.version}/.match path.basename
+
+ unless $1.to_s.empty?
+ name = $1
+ else
+ print "Formula name [#{path.stem}]: "
+ gots = $stdin.gets.chomp
+ if gots.empty?
+ name = path.stem
+ else
+ name = gots
+ end
+ end
+
+ __make url, name
+end
+
+
def info name
require 'formula'