Sha256: be4195198179520df98b5590cad4828c1e9a47f846b5623d423a7dd3fd92fce0

Contents?: true

Size: 1.46 KB

Versions: 7

Compression:

Stored size: 1.46 KB

Contents

require 'optparse'
require 'vagrant-skytap/command/helpers'

module VagrantPlugins
  module Skytap
    module Command
      module PublishUrl
        class Delete < Vagrant.plugin("2", :command)
          include Command::Helpers

          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
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vagrant-skytap-0.2.3 lib/vagrant-skytap/command/publish_url/delete.rb
vagrant-skytap-0.2.2 lib/vagrant-skytap/command/publish_url/delete.rb
vagrant-skytap-0.2.1 lib/vagrant-skytap/command/publish_url/delete.rb
vagrant-skytap-0.2.0 lib/vagrant-skytap/command/publish_url/delete.rb
vagrant-skytap-0.1.11 lib/vagrant-skytap/command/publish_url/delete.rb
vagrant-skytap-0.1.10 lib/vagrant-skytap/command/publish_url/delete.rb
vagrant-skytap-0.1.9 lib/vagrant-skytap/command/publish_url/delete.rb