Module: Ronin::CLI::KeyOptions Private

Included in:
Commands::CipherCommand, Commands::Hmac, Commands::Xor
Defined in:
lib/ronin/cli/key_options.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Adds the --key and --key-file options to a command.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#keyString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The key string.

Returns:

  • (String)

Since:

  • 2.0.0



56
57
58
# File 'lib/ronin/cli/key_options.rb', line 56

def key
  @key
end

Class Method Details

.included(command) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds the --key and --key-file options to the including command.

Parameters:

Since:

  • 2.0.0



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ronin/cli/key_options.rb', line 31

def self.included(command)
  command.option :key, short: '-k',
                       value: {
                         type:  String,
                         usage: 'STRING'
                       },
                       desc: 'The key String' do |string|
                         @key = string
                       end

  command.option :key_file, short: '-K',
                            value: {
                              type:  String,
                              usage: 'FILE'
                            },
                            desc: 'The key file' do |path|
                              @key = File.binread(path)
                            rescue Errno::ENOENT
                              raise(OptionParser::InvalidArgument,"no such file or directory: #{path.inspect}")
                            end
end