Class: HexaPDF::CLI::Application

Inherits:
CmdParse::CommandParser
  • Object
show all
Defined in:
lib/hexapdf/cli.rb

Overview

The CmdParse::CommandParser class that is used for running the CLI application.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

:nodoc:



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

def initialize #:nodoc:
  super(handle_exceptions: :no_help)
  main_command.options.program_name = "hexapdf"
  main_command.options.version = HexaPDF::VERSION
  add_command(HexaPDF::CLI::Info.new)
  add_command(HexaPDF::CLI::Files.new)
  add_command(HexaPDF::CLI::Images.new)
  add_command(HexaPDF::CLI::Inspect.new)
  add_command(HexaPDF::CLI::Modify.new)
  add_command(HexaPDF::CLI::Optimize.new)
  add_command(HexaPDF::CLI::Merge.new)
  add_command(CmdParse::HelpCommand.new)
  add_command(CmdParse::VersionCommand.new)

  @force = false
  global_options.on("--[no-]force", "Force overwriting existing files. Default: false") do |f|
    @force = f
  end
end

Instance Attribute Details

#forceObject (readonly)

Specifies whether an operation should be forced. For example, if an existing file should be overwritten.



64
65
66
# File 'lib/hexapdf/cli.rb', line 64

def force
  @force
end

Instance Method Details

#parse(argv = ARGV) ⇒ Object

:nodoc:



86
87
88
89
# File 'lib/hexapdf/cli.rb', line 86

def parse(argv = ARGV) #:nodoc:
  ARGV.unshift('help') if ARGV.empty?
  super
end