Module: VMC::Start::TargetInteractions

Defined in:
lib/vmc/cli/start/target_interactions.rb

Instance Method Summary collapse

Instance Method Details

#ask_organizationObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/vmc/cli/start/target_interactions.rb', line 3

def ask_organization
  orgs = client.organizations(:depth => 0)

  if orgs.empty?
    unless quiet?
      line
      line c("There are no organizations.", :warning)
      line "You may want to create one with #{c("create-org", :good)}."
    end
  elsif orgs.size == 1 && !input.interactive?(:organization)
    orgs.first
  else
    ask("Organization",
        :choices => orgs.sort_by(&:name),
        :display => proc(&:name))
  end
end

#ask_space(org) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vmc/cli/start/target_interactions.rb', line 21

def ask_space(org)
  spaces = org.spaces(:depth => 0)

  if spaces.empty?
    unless quiet?
      line
      line c("There are no spaces in #{b(org.name)}.", :warning)
      line "You may want to create one with #{c("create-space", :good)}."
    end
  elsif spaces.size == 1 && !input.interactive?(:spaces)
    spaces.first
  else
    ask("Space", :choices => spaces, :display => proc(&:name))
  end
end