Class: KmsTools::CLI::Helpers

Inherits:
Object
  • Object
show all
Defined in:
lib/kms-tools/cli/helpers.rb

Overview

General purpose helper functions for the CLI

Class Method Summary collapse

Class Method Details

.get_save_path(params) ⇒ String

Prompts the user for a path to save a file. Optionally providers a default suggestion.

Parameters:

  • params (Hash)

Options Hash (params):

  • :prompt (String)

    Prompt text to display

  • :suggested_path (String)

    Optional path to suggest to user and use a default if no additional input is given

Returns:

  • (String)

    path



20
21
22
23
24
25
26
# File 'lib/kms-tools/cli/helpers.rb', line 20

def self.get_save_path(params)
  prompt = params[:prompt].nil? ? "Save to" : params[:prompt]
  prompt << " (#{params[:suggested_path]})" if params[:suggested_path]
  prompt << ": "
  entered_path = KmsTools::CLI::Output.ask(prompt, String)
  entered_path.empty? ? params[:suggested_path] : entered_path
end

.select_key(kms) ⇒ String

Prompts the user to select a key alias from a list of key aliases available to current credentials

Parameters:

  • kms (Object)

    KMS client object

Returns:

  • (String)

    key alias



10
11
12
# File 'lib/kms-tools/cli/helpers.rb', line 10

def self.select_key(kms)
  Output.select_from_list("Choose which key alias to use as the base Customer Master Key:", kms.available_aliases)
end