brew-man: Rubify, make an internal command.
Closes Homebrew/homebrew#32472.
This commit is contained in:
parent
86ded7833c
commit
dfce2bb7c7
@ -1,51 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
shopt -s nullglob
|
||||
|
||||
SOURCE_PATH="$HOMEBREW_REPOSITORY/Library/Homebrew/manpages"
|
||||
TARGET_PATH="$HOMEBREW_REPOSITORY/share/man/man1"
|
||||
LINKED_PATH="$HOMEBREW_PREFIX/share/man/man1"
|
||||
|
||||
|
||||
die (){
|
||||
echo $1
|
||||
exit 1
|
||||
}
|
||||
|
||||
test "$1" = '--link' || \
|
||||
test "$1" = '-l' && {
|
||||
[[ $TARGET_PATH == $LINKED_PATH ]] && exit 0
|
||||
|
||||
for page in "$TARGET_PATH"/*.1
|
||||
do
|
||||
ln -s $page $LINKED_PATH
|
||||
done
|
||||
exit 0
|
||||
}
|
||||
|
||||
/usr/bin/which ronn &>/dev/null || die "You need to \"gem install ronn\" and put it in your path."
|
||||
|
||||
test "$1" = '--server' || \
|
||||
test "$1" = '-s' && {
|
||||
echo "Man page test server: http://localhost:1207/"
|
||||
echo "Control-C to exit."
|
||||
ronn --server $SOURCE_PATH/*
|
||||
exit 0
|
||||
}
|
||||
|
||||
echo "Writing manpages to $TARGET_PATH"
|
||||
|
||||
for i in "$SOURCE_PATH"/*.md
|
||||
do
|
||||
# Get the filename only, without the .md extension
|
||||
j=`basename $i`
|
||||
target_file="$TARGET_PATH/${j%\.md}"
|
||||
|
||||
ronn --roff --pipe --organization='Homebrew' --manual='brew' $i > $target_file
|
||||
done
|
||||
|
||||
if test "$1" = '--verbose' || test "$1" = '-v'
|
||||
then
|
||||
man $target_file
|
||||
fi
|
37
Library/Homebrew/cmd/man.rb
Executable file
37
Library/Homebrew/cmd/man.rb
Executable file
@ -0,0 +1,37 @@
|
||||
require 'formula'
|
||||
|
||||
module Homebrew
|
||||
SOURCE_PATH=HOMEBREW_REPOSITORY/"Library/Homebrew/manpages"
|
||||
TARGET_PATH=HOMEBREW_REPOSITORY/"share/man/man1"
|
||||
LINKED_PATH=HOMEBREW_PREFIX/"share/man/man1"
|
||||
|
||||
def man
|
||||
if ARGV.include?("--link") || ARGV.include?("-l")
|
||||
Dir["#{TARGET_PATH}/*.1"].each do |page|
|
||||
FileUtils.ln_s page, LINKED_PATH
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
which("ronn") || odie("You need to \"gem install ronn\" and put it in your path.")
|
||||
|
||||
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}"
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user