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.

Parameters:

  • path (String)

    The path to the file.

  • format (:gzip, :bzip2, :xz)

    The compression format of the file.

  • append (Boolean) (defaults to: false)

    Indicates that new words should be appended to the file instead of overwriting the file.

Returns:

  • (String)

    The shellescaped command string.

Raises:

  • (UnknownFormat)

    The given format was not :gzip, :bzip2, or :xz.

Since:

  • 1.0.0



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/wordlist/compression/writer.rb', line 39

def self.command(path, format: , append: false)
  command  = COMMANDS.fetch(format) do
    raise(UnknownFormat,"unsupported format: #{format.inspect}")
  end

  redirect = if append then '>>'
             else           '>'
             end

  return "#{Shellwords.shellescape(command)} #{redirect} #{Shellwords.shellescape(path)}"
end