Quick Reference
CLI Commands
# Basic extraction
excavate archive.zip
# Recursive extraction
excavate -r installer.msi
# Extract specific files
excavate data.tar.gz config.json readme.txt
# Filter by pattern
excavate --filter "**/*.ttf" fonts.zip
# Combined options
excavate -r --filter "**/*.dll" installer.msiCLI Options
| Option | Short | Description |
|---|---|---|
|
| Extract nested archives |
| Extract matching files only | |
|
| Show help message |
CLI Exit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Unknown error |
2 | Target exists |
3 | Target not empty |
4 | File not found |
API Methods
Archive Class
# Create archive instance
archive = Excavate::Archive.new(path)
# Extract to directory
archive.extract # Auto-creates directory
archive.extract('/path/to/target') # Specific directory
# Extract with options
archive.extract(
recursive_packages: true, # Extract nested archives
files: ['file1.txt', 'file2.txt'], # Specific files
filter: '**/*.rb' # Pattern matching
)
# Iterate over files
archive.files do |path|
puts path
endAPI Options
| Option | Type | Description |
|---|---|---|
| String | Target directory path |
| Boolean | Extract nested archives |
| Array | Specific files to extract |
| String | Glob pattern for filtering |
Supported Formats
| Extension | Format |
|---|---|
| ZIP |
| TAR |
| TAR + GZIP |
| TAR + XZ |
| 7-Zip |
| Microsoft CAB |
| Windows Installer |
| RPM Package |
| macOS Package |
Error Classes
Excavate::Error # Base class
Excavate::TargetExistsError # Target already exists
Excavate::TargetNotEmptyError # Target not empty
Excavate::TargetNotFoundError # File not found
Excavate::UnknownArchiveError # Unknown formatError Handling
begin
archive.extract(target)
rescue Excavate::TargetExistsError
# Handle existing target
rescue Excavate::TargetNotFoundError
# Handle missing file
rescue Excavate::UnknownArchiveError
# Handle unknown format
rescue Excavate::Error => e
# Handle any Excavate error
endFilter Patterns
| Pattern | Matches |
|---|---|
| .txt files at root |
| .txt files anywhere |
| .rb files under src/ |
| .json or .yaml files |
| Test files anywhere |