Module: HexaPDF::CLI

Defined in:
lib/hexapdf/cli.rb,
lib/hexapdf/cli/form.rb,
lib/hexapdf/cli/info.rb,
lib/hexapdf/cli/batch.rb,
lib/hexapdf/cli/files.rb,
lib/hexapdf/cli/fonts.rb,
lib/hexapdf/cli/merge.rb,
lib/hexapdf/cli/split.rb,
lib/hexapdf/cli/usage.rb,
lib/hexapdf/cli/images.rb,
lib/hexapdf/cli/modify.rb,
lib/hexapdf/cli/command.rb,
lib/hexapdf/cli/inspect.rb,
lib/hexapdf/cli/optimize.rb,
lib/hexapdf/cli/image2pdf.rb,
lib/hexapdf/cli/watermark.rb

Overview

Contains the code for the hexapdf binary. The binary uses the cmdparse library (cmdparse.gettalong.org) for the command suite support.

Defined Under Namespace

Classes: Application, Batch, Command, Error, Files, Fonts, Form, Image2PDF, Images, Info, Inspect, Merge, Modify, Optimize, Split, Usage, Watermark

Class Method Summary collapse

Class Method Details

.run(args = ARGV) ⇒ Object

Runs the CLI application.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/hexapdf/cli.rb', line 62

def self.run(args = ARGV)
  Application.new.parse(args)
rescue Errno::ENOENT => e
  path = e.message.scan(/(?<= - ).*?$/).first
  $stderr.puts "Problem encountered: No such file - #{path}"
rescue StandardError => e
  $stderr.puts "Problem encountered: #{e.message}"
  unless e.kind_of?(HexaPDF::Error)
    $stderr.puts "Backtrace (last 10 lines):"
    $stderr.puts e.backtrace[0, 10]
    $stderr.puts
    $stderr.puts "--> The problem might indicate a faulty PDF or a bug in HexaPDF."
    $stderr.puts "--> Please report this at"
    $stderr.puts "-->"
    $stderr.puts "-->     https://github.com/gettalong/hexapdf/issues"
    $stderr.puts "-->"
    $stderr.puts "--> and include the information above as well as the output of running"
    $stderr.puts "--> the following command on the input PDF:"
    $stderr.puts "-->"
    $stderr.puts "-->     hexapdf info --check INPUT.PDF"
    $stderr.puts "-->"
    $stderr.puts "--> If possible, please also provide the input PDF."
    $stderr.puts "--> Thanks!"
  end
  exit(1)
end