aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/edit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/cmd/edit.rb')
-rw-r--r--Library/Homebrew/cmd/edit.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/edit.rb b/Library/Homebrew/cmd/edit.rb
new file mode 100644
index 000000000..6ab91dccf
--- /dev/null
+++ b/Library/Homebrew/cmd/edit.rb
@@ -0,0 +1,26 @@
+require 'formula'
+
+module Homebrew extend self
+ def edit
+ if ARGV.named.empty?
+ # EDITOR isn't a good fit here, we need a GUI client that actually has
+ # a UI for projects, so apologies if this wasn't what you expected,
+ # please improve it! :)
+ exec 'mate', HOMEBREW_REPOSITORY/"bin/brew",
+ HOMEBREW_REPOSITORY/'README.md',
+ HOMEBREW_REPOSITORY/".gitignore",
+ *Dir[HOMEBREW_REPOSITORY/"Library/*"]
+ else
+ # Don't use ARGV.formulae as that will throw if the file doesn't parse
+ paths = ARGV.named.map do |name|
+ HOMEBREW_REPOSITORY/"Library/Formula/#{Formula.caniconical_name name}.rb"
+ end
+ unless ARGV.force?
+ paths.each do |path|
+ raise FormulaUnavailableError, path.basename('.rb').to_s unless path.file?
+ end
+ end
+ exec_editor *paths
+ end
+ end
+end