Class: Pgchief::Prompt::CreateUser

Inherits:
Base
  • Object
show all
Defined in:
lib/pgchief/prompt/create_user.rb

Overview

Class to prompt for user creation details

Instance Attribute Summary

Attributes inherited from Base

#params

Instance Method Summary collapse

Methods inherited from Base

call, #initialize, #klassify, #prompt, #yes_or_no

Constructor Details

This class inherits a constructor from Pgchief::Prompt::Base

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pgchief/prompt/create_user.rb', line 7

def call
  username = prompt.ask('Username:')
  password = prompt.mask('Password:')
  result   = Pgchief::Command::UserCreate.call(username, password)

  prompt.say result

  yes_or_no(
    "Give \"#{username}\" access to database(s)?",
    yes: -> { Pgchief::Prompt::GrantDatabasePrivileges.call(username, password) }
  )
end