Class: Cabriolet::HLP::CommandHandler
- Inherits:
-
Commands::BaseCommandHandler
- Object
- Commands::BaseCommandHandler
- Cabriolet::HLP::CommandHandler
- Defined in:
- lib/cabriolet/hlp/command_handler.rb
Overview
Command handler for HLP (Help) format
This handler implements the unified command interface for HLP files, wrapping the existing HLP::Decompressor and HLP::Compressor classes. Supports both QuickHelp and Windows Help formats.
Instance Method Summary collapse
-
#create(output, files = [], options = {}) ⇒ void
Create a new HLP archive.
-
#extract(file, output_dir = nil, _options = {}) ⇒ void
Extract files from HLP archive.
-
#info(file, _options = {}) ⇒ void
Display detailed HLP file information.
-
#list(file, _options = {}) ⇒ void
List HLP file contents.
-
#test(file, _options = {}) ⇒ void
Test HLP file integrity.
Methods inherited from Commands::BaseCommandHandler
Constructor Details
This class inherits a constructor from Cabriolet::Commands::BaseCommandHandler
Instance Method Details
#create(output, files = [], options = {}) ⇒ void
This method returns an undefined value.
Create a new HLP archive
Creates an HLP file from source files using QuickHelp format.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cabriolet/hlp/command_handler.rb', line 70 def create(output, files = [], = {}) raise ArgumentError, "No files specified" if files.empty? files.each do |f| raise ArgumentError, "File does not exist: #{f}" unless File.exist?(f) end format = parse_format_option([:format]) if format == :winhelp create_winhelp(output, files, ) else create_quickhelp(output, files, ) end end |
#extract(file, output_dir = nil, _options = {}) ⇒ void
This method returns an undefined value.
Extract files from HLP archive
Extracts all files from the HLP file to the specified output directory. Supports both QuickHelp and Windows Help formats.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/cabriolet/hlp/command_handler.rb', line 45 def extract(file, output_dir = nil, = {}) validate_file_exists(file) output_dir ||= "." output_dir = ensure_output_dir(output_dir) decompressor = Decompressor.new header = decompressor.open(file) count = decompressor.extract_all(header, output_dir) decompressor.close(header) puts "Extracted #{count} file(s) to #{output_dir}" end |
#info(file, _options = {}) ⇒ void
This method returns an undefined value.
Display detailed HLP file information
Shows comprehensive information about the HLP structure, including format type, file count, and metadata.
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cabriolet/hlp/command_handler.rb', line 94 def info(file, = {}) validate_file_exists(file) decompressor = Decompressor.new header = decompressor.open(file) display_hlp_info(header, file) decompressor.close(header) end |
#list(file, _options = {}) ⇒ void
This method returns an undefined value.
List HLP file contents
Displays information about the HLP file including format type, and lists all contained files with their sizes.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cabriolet/hlp/command_handler.rb', line 24 def list(file, = {}) validate_file_exists(file) decompressor = Decompressor.new header = decompressor.open(file) display_header(header, file) display_files(decompressor, header) decompressor.close(header) end |
#test(file, _options = {}) ⇒ void
This method returns an undefined value.
Test HLP file integrity
Verifies the HLP file structure.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/cabriolet/hlp/command_handler.rb', line 112 def test(file, = {}) validate_file_exists(file) decompressor = Decompressor.new header = decompressor.open(file) puts "Testing #{file}..." # TODO: Implement full integrity testing format_name = if header.respond_to?(:version) version_value = header.version # Convert BinData objects to integer for comparison version_int = version_value.to_i if version_value.respond_to?(:to_i) if version_value.is_a?(Integer) || version_int&.positive? "QUICKHELP v#{version_value}" elsif version_value.is_a?(Symbol) version_value.to_s.upcase.sub("WINHELP", "WinHelp ") else "unknown" end end puts "OK: HLP file structure is valid (#{format_name} format)" decompressor.close(header) end |