Sha256: 0c527ce5bd08d4d2bbbaf02aac6c5773ba7221a70e8f2fea485500e8e22b44f5
Contents?: true
Size: 1008 Bytes
Versions: 1
Compression:
Stored size: 1008 Bytes
Contents
require 'rbkb/cli' # Reverses a hexdump back to raw data. Designed to work with hexdumps created # by Unix utilities like 'xxd' as well as 'hexdump -C'. class Rbkb::Cli::Dedump < Rbkb::Cli::Executable def initialize(*args) super(*args) @opts[:len] ||= 16 end def make_parser() arg = super() arg.banner += " <input-file | blank for stdin>" arg.on("-l", "--length LEN", Numeric, "Bytes per line in hexdump (default: #{@opts[:len]})") do |l| bail("Length must be greater than zero") unless (@opts[:len] = l) > 0 end return arg end def parse(*args) super(*args) parse_file_argument(:indat) parse_catchall() end def go(*args) super(*args) # Default to standard input @opts[:indat] ||= @stdin.read() self.exit(1) unless((@opts[:len] ||= @opts[:indat].length) > 0) begin @opts[:indat].dehexdump( :len => @opts[:len], :out => @stdout) rescue bail "Error: #{$!}" end self.exit(0) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
emonti-rbkb-0.6.2 | lib/rbkb/cli/dedump.rb |