class Ronin::CLI::Commands::Archive
Archive
the files.
## Usage
ronin archive [option] [FILE ...]
## Options
-f, --format tar|zip Archive format -o, --output PATH Archived file path
## Arguments
FILE ... Optional file(s) to archive
@since 2.1.0
Constants
- ARCHIVE_FORMATS
Mapping of archive file extensions and their formats.
Public Instance Methods
run(*files)
click to toggle source
Runs the ‘archive` sub-command.
@param [Array<String>] files
File arguments.
# File lib/ronin/cli/commands/archive.rb, line 76 def run(*files) unless (output = options[:output]) print_error "must specify the --output option" exit(-1) end format = options.fetch(:format) do ARCHIVE_FORMATS.fetch(File.extname(output)) do print_error "must either specify --format or a .tar or .zip output file" exit(1) end end unless files.empty? Ronin::Support::Archive.send(format,output) do |archive| files.each do |file| archive.add_file(file) do |io| File.open(file, 'rb') do |opened_file| io.write(opened_file.readpartial(4096)) until opened_file.eof? end end end end end end