From bd42901fa7146729395706e019b3bc2e445e4b7c Mon Sep 17 00:00:00 2001 From: Baptiste Fontaine <baptiste.fontaine@batch.com> Date: Mon, 15 Jun 2015 12:41:12 +0200 Subject: [PATCH] 'brew man': abort if a formula is given Closes Homebrew/homebrew#40735. Closes Homebrew/homebrew#40736. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr> --- Library/Homebrew/cmd/man.rb | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/cmd/man.rb index c1a202156e..bba81efa52 100644 --- a/Library/Homebrew/cmd/man.rb +++ b/Library/Homebrew/cmd/man.rb @@ -6,32 +6,30 @@ module Homebrew LINKED_PATH=HOMEBREW_PREFIX/"share/man/man1" def man - if ARGV.include?("--link") || ARGV.include?("-l") + abort <<-EOS.undent unless ARGV.named.empty? + This command updates the brew manpage and does not take formula names. + EOS + + if ARGV.flag? "--link" + abort <<-EOS.undent if TARGET_PATH == LINKED_PATH + The target path is the same as the linked one, aborting. + EOS Dir["#{TARGET_PATH}/*.1"].each do |page| FileUtils.ln_s page, LINKED_PATH return end - end + else + Homebrew.install_gem_setup_path! "ronn" - Homebrew.install_gem_setup_path! "ronn" - - if ARGV.include?("--server") || ARGV.include?("-s") - puts "Man page test server: http://localhost:1207/" - puts "Control-C to exit." - system "ronn", "--server", Dir["#{SOURCE_PATH}/*"] - return - end + puts "Writing manpages to #{TARGET_PATH}" - puts "Writing manpages to #{TARGET_PATH}" - - target_file = nil - Dir["#{SOURCE_PATH}/*.md"].each do |source_file| - target_file = TARGET_PATH/File.basename(source_file, ".md") - safe_system "ronn --roff --pipe --organization='Homebrew' --manual='brew' #{source_file} > #{target_file}" - end + target_file = nil + Dir["#{SOURCE_PATH}/*.md"].each do |source_file| + target_file = TARGET_PATH/File.basename(source_file, ".md") + safe_system "ronn --roff --pipe --organization='Homebrew' --manual='brew' #{source_file} > #{target_file}" + end - if ARGV.include?("--verbose") || ARGV.include?("-v") - system "man", target_file + system "man", target_file if ARGV.flag? "--verbose" end end end -- GitLab