Class: CF::User

Inherits:
Command show all
Defined in:
lib/cf/cli/user.rb

Constant Summary

Constants included from Dots

Dots::COLOR_CODES, Dots::DOT_COUNT, Dots::DOT_TICK

Instance Method Summary collapse

Methods inherited from Command

add_callback, after, around, before, callbacks, callbacks_for, ensuring, flag, #invoke_task

Methods included from Interactive

#ask, #force?, #handler, #input_state, #list_choices, #prompt

Methods included from Dots

b, c, #color?, #dots!, #stop_dots!, #with_progress

Instance Method Details

#create(email = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cf/cli/user.rb', line 15

def create(email = nil)
  email ||= input(:email)
  password = input(:password)
  verify = input(:verify)

  if password != verify
    err "Passwords don't match."
    return
  end

  with_progress("Creating user") do
    client.register(email, password)
  end
end

#delete(email) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/cf/cli/user.rb', line 34

def delete(email)
  return unless input(:really, email)

  with_progress("Deleting #{c(email, :blue)}") do
    client.user(email).delete!
  end
ensure
  forget(:really)
end

#passwd(email = nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cf/cli/user.rb', line 54

def passwd(email = nil)
  email ||= input(:email)
  password = input(:password)
  verify = input(:verify)

  if password != verify
    err "Passwords don't match."
    return
  end

  with_progress("Changing password") do
    user = client.user(email)
    user.password = password
    user.update!
  end
end