Class: Ronin::DB::CLI::Commands::List Private

Inherits:
Ronin::DB::CLI::Command show all
Includes:
CommandKit::Options::Verbose, CommandKit::Printing, CommandKit::Printing::Fields, CommandKit::Printing::Indent
Defined in:
lib/ronin/db/cli/commands/list.rb

Overview

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

Lists entries in the ~/.config/ronin-db/database.yml configuration file.

Usage

ronin-db list [options] [NAME]

Options

-v, --verbose                    Enables verbose output
-h, --help                       Print help information

Arguments

[NAME]                           Optional DB name to list

Constant Summary collapse

HIDDEN_PASSWORD =

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

Default hidden password placeholder.

'*******'

Instance Method Summary collapse

Instance Method Details

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.

Prints a specific entry in the database.yml file.

Parameters:

  • name (Symbol)

    The database name.

  • hash (Hash{Symbol => String,Integer})

    The configuration hash for the database.



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/ronin/db/cli/commands/list.rb', line 106

def print_database(name,hash)
  puts "[ #{name} ]"
  puts

  if hash[:password]
    # blank out the password by default
    hash = hash.merge(password: HIDDEN_PASSWORD)
  end

  indent(2) do
    print_fields(hash)
  end
end

#run(name = nil) ⇒ 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.

Runs the ronin-db list command.

Parameters:

  • name (String, nil) (defaults to: nil)

    The optional database name to list.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ronin/db/cli/commands/list.rb', line 72

def run(name=nil)
  config = ConfigFile.load

  if name
    unless (hash = config[name.to_sym])
      print_error "unknown database #{name.inspect}"
      exit(1)
    end

    print_database(name,hash)
  else
    config.each do |name,hash|
      if verbose?
        print_database(name,hash)
        puts
      else
        puts name
      end
    end
  end
end