Merge pull request #5301 from GauthamGoli/unlink-args
unlink: Use CLI::Parser to parse args
This commit is contained in:
commit
4abb5754d7
@ -7,15 +7,35 @@
|
|||||||
#: be unlinked, but will not actually unlink or delete any files.
|
#: be unlinked, but will not actually unlink or delete any files.
|
||||||
|
|
||||||
require "ostruct"
|
require "ostruct"
|
||||||
|
require "cli_parser"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
|
def unlink_args
|
||||||
|
Homebrew::CLI::Parser.new do
|
||||||
|
usage_banner <<~EOS
|
||||||
|
`unlink` [<options>] <formula>
|
||||||
|
|
||||||
|
Remove symlinks for <formula> from the Homebrew prefix. This can be useful
|
||||||
|
for temporarily disabling a formula:
|
||||||
|
`brew unlink` <formula> `&&` <commands> `&& brew link` <formula>
|
||||||
|
EOS
|
||||||
|
switch "-n", "--dry-run",
|
||||||
|
description: "List all files which would be unlinked, but will not actually unlink or "\
|
||||||
|
"delete any files."
|
||||||
|
switch :verbose
|
||||||
|
switch :debug
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def unlink
|
def unlink
|
||||||
raise KegUnspecifiedError if ARGV.named.empty?
|
unlink_args.parse
|
||||||
|
|
||||||
|
raise KegUnspecifiedError if args.remaining.empty?
|
||||||
|
|
||||||
mode = OpenStruct.new
|
mode = OpenStruct.new
|
||||||
mode.dry_run = true if ARGV.dry_run?
|
mode.dry_run = true if args.dry_run?
|
||||||
|
|
||||||
ARGV.kegs.each do |keg|
|
ARGV.kegs.each do |keg|
|
||||||
if mode.dry_run
|
if mode.dry_run
|
||||||
@ -26,7 +46,7 @@ module Homebrew
|
|||||||
|
|
||||||
keg.lock do
|
keg.lock do
|
||||||
print "Unlinking #{keg}... "
|
print "Unlinking #{keg}... "
|
||||||
puts if ARGV.verbose?
|
puts if args.verbose?
|
||||||
puts "#{keg.unlink(mode)} symlinks removed"
|
puts "#{keg.unlink(mode)} symlinks removed"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user