Method: Wordlist::Compression::Writer.command
- Defined in:
- lib/wordlist/compression/writer.rb
.command(path, format:, append: false) ⇒ String
Returns the command to write to the compressed wordlist.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/wordlist/compression/writer.rb', line 35 def self.command(path, format: , append: false) case format when :gzip, :bzip2, :xz command = format.to_s redirect = if append then '>>' else '>' end "#{command} #{redirect} #{Shellwords.shellescape(path)}" when :zip if append raise(AppendNotSupported,"zip format does not support appending to files within pre-existing archives: #{path.inspect}") end "zip -q #{Shellwords.shellescape(path)} -" when :"7zip" if append raise(AppendNotSupported,"7zip format does not support appending to files within pre-existing archives: #{path.inspect}") end "7za a -si #{Shellwords.shellescape(path)} >/dev/null" else raise(UnknownFormat,"unsupported output format: #{format.inspect}") end end |