Skip to content

Commit

Permalink
Read gzipped and plain man page from standard location if exists with…
Browse files Browse the repository at this point in the history
… -h manpage
  • Loading branch information
aerostitch committed Apr 9, 2018
1 parent ba8f1ab commit 030f144
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/asciidoctor/cli/options.rb
Expand Up @@ -138,6 +138,13 @@ def parse!(args)
if topic == 'manpage'
if ::File.exist?(manpage_path = (::File.join ::Asciidoctor::ROOT_PATH, 'man', 'asciidoctor.1'))
$stdout.puts(::IO.read manpage_path)
elsif ::File.exist?(manpage_path = (::File.join ::Asciidoctor::ROOT_PATH, '..', '..', 'share', 'man', 'man1', 'asciidoctor.1'))
$stdout.puts(::IO.read manpage_path) # This one is when you have installed the non-gzip version in a standard structure path
elsif ::File.exist?(manpage_path = (::File.join ::Asciidoctor::ROOT_PATH, '..', '..', 'share', 'man', 'man1', 'asciidoctor.1.gz'))
require 'zlib'
gz = Zlib::GzipReader.open(manpage_path)
$stdout.puts(gz.read)
gz.close
else
$stderr.puts 'asciidoctor: FAILED: man page not found; try `man asciidoctor`'
return 1
Expand Down

0 comments on commit 030f144

Please sign in to comment.