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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/vagrant-skytap/command/publish_url/delete.rb', line 33

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