Class: VMC::Start::Target

Inherits:
Base
  • Object
show all
Defined in:
lib/vmc/cli/start/target.rb

Instance Method Summary collapse

Methods inherited from Base

#displayed_target?, #precondition

Methods inherited from CLI

#check_logged_in, #check_target, #client, client, client=, #client_target, #color_enabled?, #default_action, #ensure_config_dir, #err, #execute, #fail, #force?, #invalidate_client, #log_error, #name_list, #no_v2, #one_of, #precondition, #quiet?, #remove_target_info, #sane_target_url, #save_target_info, #save_targets, #set_target, #table, #target_file, #target_info, #targets_info, #tokens_file, #user_colors, #v2?, #verbose?

Methods included from VMC::Spacing

#indented, #justify, #line, #lines, #quiet?, #spaced, #start_line, #tabular, #text_width, #trim_escapes

Methods included from Interactive

#ask, #handler, #input_state, #list_choices, #prompt, #show_default

Instance Method Details

#targetObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vmc/cli/start/target.rb', line 43

def target
  if !input.given?(:url) && !input.given?(:organization) && !input.given?(:space)
    display_target
    display_org_and_space unless quiet?
    return
  end

  if input.given?(:url)
    target = sane_target_url(input[:url])
    with_progress("Setting target to #{c(target, :name)}") do
      client(target).info # check that it's valid before setting
      set_target(target)
    end
  end

  return unless v2? && client.logged_in?

  if input.given?(:organization) || input.given?(:space)
    info = target_info

    select_org_and_space(input, info)

    save_target_info(info)
  end

  return if quiet?

  invalidate_client

  line
  display_target
  display_org_and_space
end