Sha256: 6e6d53ce4151984969e423d42eb97ca2997e73983d57eb88b3444f1d4cde0029

Contents?: true

Size: 1.48 KB

Versions: 10

Compression:

Stored size: 1.48 KB

Contents

require 'optparse'

require 'vagrant/util/install_cli_autocomplete'

module VagrantPlugins
  module CommandAutocomplete
    module Command
      class Install < Vagrant.plugin("2", :command)
        def execute
          options = {
            shells: []
          }

          opts = OptionParser.new do |o|
            o.banner = "Usage: vagrant autocomplete install [-h] [shell name]"
            o.separator ""
            o.separator "Available shells: #{Vagrant::Util::InstallCLIAutocomplete::SUPPORTED_SHELLS.keys.join(' ')}"
            o.separator ""
            o.separator "Options:"
            o.separator ""

            o.on("-b", "--bash", "Install bash autocomplete") do |c|
              options[:shells].append("bash")
            end

            o.on("-z", "--zsh", "Install zsh autocomplete") do |c|
              options[:shells].append("zsh")
            end
          end

          # Parse the options
          argv = parse_options(opts)
          return if !argv
          raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0

          written_paths = Vagrant::Util::InstallCLIAutocomplete.install(options[:shells])
          if written_paths && written_paths.length > 0
            @env.ui.info(I18n.t("vagrant.autocomplete.installed", paths: written_paths.join("\n- ")))
          else
            @env.ui.info(I18n.t("vagrant.autocomplete.not_installed"))
          end

          # Success, exit status 0
          0
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/commands/autocomplete/command/install.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/commands/autocomplete/command/install.rb
vagrant-unbundled-2.3.3.0 plugins/commands/autocomplete/command/install.rb
vagrant-unbundled-2.3.2.0 plugins/commands/autocomplete/command/install.rb
vagrant-unbundled-2.2.19.0 plugins/commands/autocomplete/command/install.rb
vagrant-unbundled-2.2.18.0 plugins/commands/autocomplete/command/install.rb
vagrant-unbundled-2.2.16.0 plugins/commands/autocomplete/command/install.rb
vagrant-unbundled-2.2.14.0 plugins/commands/autocomplete/command/install.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/commands/autocomplete/command/install.rb
vagrant-unbundled-2.2.10.0 plugins/commands/autocomplete/command/install.rb