Class: VagrantPlugins::Skytap::Command::PublishUrl::Delete

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/vagrant-skytap/command/publish_url/delete.rb

Instance Method Summary collapse

Methods included from Helpers

#fetch_environment, #machine_names, #target_skytap_vms, #target_vms

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vagrant-skytap/command/publish_url/delete.rb', line 11

def execute
  options = {}

  opts = OptionParser.new do |o|
    o.separator ""
    o.separator "Deletes all published URLs for this project, including any"
    o.separator "created through the Skytap UI."

    o.banner = "Usage: vagrant publish-url delete [options]"
    o.separator ""
    o.separator "Options:"
    o.separator ""

    o.on("-f", "--force", "Delete without prompting") do |f|
      options[:force] = f
    end
  end

  return unless argv = parse_options(opts)

  if publish_sets = fetch_environment.publish_sets.presence
    unless options[:force]
      confirm = @env.ui.ask(I18n.t("vagrant_skytap.commands.publish_urls.confirm_delete"))
      return unless confirm.downcase == 'y'
    end
    publish_sets.each(&:delete)
    @env.ui.info(I18n.t("vagrant_skytap.commands.publish_urls.deleted"))
  else
    @env.ui.info(I18n.t("vagrant_skytap.commands.publish_urls.empty_list"))
  end

  # Success, exit status 0
  0
end