class Mortar::InstallCompletionsCommand
Constants
- COMPLETION_FILE_PATH
- DEFAULT_PATHS
Public Instance Methods
execute()
click to toggle source
# File lib/mortar/install_completions_command.rb, line 25 def execute return uninstall if remove? installed = [] DEFAULT_PATHS.each do |path| next unless File.directory?(File.dirname(path)) begin FileUtils.ln_sf(COMPLETION_FILE_PATH, path) installed << path rescue Errno::EACCES, Errno::EPERM nil # To keep Mr. Rubocop happy end end if installed.empty? warn "Installation failed" warn "Try with sudo or set up user bash completions in ~/.bash_completion to include files from ~/.bash_completion.d" exit 1 else puts "Completions installed to:" installed.each do |path| puts " - #{path}" end puts puts "The completions will be reloaded when you start a new shell." puts "To load now, use:" puts pastel.cyan(" source \"#{COMPLETION_FILE_PATH}\"") exit 0 end end
uninstall()
click to toggle source
# File lib/mortar/install_completions_command.rb, line 58 def uninstall failures = false DEFAULT_PATHS.each do |path| begin if File.exist?(path) File.unlink(path) puts "Removed #{path}" end rescue Errno::EACCESS, Errno::EPERM failures = true warn "Failed to remove #{path} : permission denied" end end exit 1 unless failures end