summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2015-05-31 23:38:06 -0600
committerDan Allen <dan.j.allen@gmail.com>2015-05-31 23:38:06 -0600
commit21af17707ef78610718afbdf47fb123bfdfd2e7b (patch)
tree3379b624cc13bd8dd5b06bb008d673d8b9c3ac71 /bin
parente737149f2a1b05551c1f760d40a20036b6cd0f4c (diff)
print Asciidoctor PDF version in CLI output
- trap -V and --version flags and -v flag when used alone - prepending Asciidoctor PDF version to version output
Diffstat (limited to 'bin')
-rwxr-xr-xbin/asciidoctor-pdf17
1 files changed, 15 insertions, 2 deletions
diff --git a/bin/asciidoctor-pdf b/bin/asciidoctor-pdf
index a10876c4..083860bc 100755
--- a/bin/asciidoctor-pdf
+++ b/bin/asciidoctor-pdf
@@ -4,9 +4,22 @@ require_relative '../lib/asciidoctor-pdf'
require 'asciidoctor/cli'
options = Asciidoctor::Cli::Options.new backend: 'pdf', header_footer: true
+
+# FIXME provide an API in Asciidoctor for sub-components to print version information
+unless ARGV != ['-v'] && (ARGV & ['-V', '--version']).empty?
+ $stdout.write %(Asciidoctor PDF #{Asciidoctor::Pdf::VERSION} using )
+ # NOTE the print_version method was added in Asciidoctor 1.5.2
+ if options.respond_to? :print_version
+ options.print_version
+ else
+ puts %(Asciidoctor #{::Asciidoctor::VERSION} [http://asciidoctor.org])
+ end
+ exit 0
+end
+
# FIXME This is a really bizarre API. Please make me simpler.
-result = options.parse! ARGV
-if Integer === result
+case (result = options.parse! ARGV)
+when Integer
exit result
else
invoker = Asciidoctor::Cli::Invoker.new options