class RHC::Commands::Setup

Public Instance Methods

run() click to toggle source
# File lib/rhc/commands/setup.rb, line 34
    def run
      if options.autocomplete
        src = File.join(File.join(Gem.loaded_specs['rhc'].full_gem_path, "autocomplete"), "rhc_bash")
        dest = File.join(RHC::Config.home_conf_dir, "bash_autocomplete")

        FileUtils.mkdir_p(RHC::Config.home_conf_dir)
        FileUtils.cp(src, dest)

        say <<-LINE.strip_heredoc
          To enable tab-completion for RHC under Bash shells, add the following command to
          your .bashrc or .bash_profile file:

            . #{dest}

          Save your shell and then restart. Type "rhc" and then hit the TAB key twice to
          trigger completion of your command.

          Tab-completion is not available in the Windows terminal.
          LINE
        return 0
      end

      raise OptionParser::InvalidOption, "Setup can not be run with the --noprompt option" if options.noprompt
      RHC::RerunWizard.new(config, options).run ?  0 : 1
    end