aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/pin.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/cmd/pin.rb')
-rw-r--r--Library/Homebrew/cmd/pin.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/pin.rb b/Library/Homebrew/cmd/pin.rb
new file mode 100644
index 000000000..26b487a0d
--- /dev/null
+++ b/Library/Homebrew/cmd/pin.rb
@@ -0,0 +1,16 @@
+require 'formula'
+
+module Homebrew extend self
+ def pin
+ if Process.uid.zero? and not File.stat(HOMEBREW_BREW_FILE).uid.zero?
+ abort "Cowardly refusing to `sudo pin'"
+ end
+ raise FormulaUnspecifiedError if ARGV.named.empty?
+ ARGV.formulae.each do |fmla|
+ f = Formula.factory(fmla.to_s)
+ onoe "Cannot pin uninstalled formula #{f.name}!" unless f.pinable?
+ opoo "Formula #{f.name} already pinned!" if f.pinable? and f.pinned?
+ f.pin if f.pinable? and not f.pinned?
+ end
+ end
+end