Class: Sym::App::Commands::BashCompletion
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Sym::App::Commands::BashCompletion
- Defined in:
- lib/sym/app/commands/bash_completion.rb
Constant Summary
Constants included from Sym
Instance Method Summary collapse
Methods included from Sym
config, default_key, default_key?, default_key_file
Constructor Details
This class inherits a constructor from Sym::App::Commands::BaseCommand
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sym/app/commands/bash_completion.rb', line 14 def execute file = opts[:bash_support] out = '' Sym::Constants.config.each_pair do |key, config| script_name = key.to_s # This removes the old version of this file. remove_old_version(out, config[:dest]) if File.exist?(config[:dest]) && File.read(config[:source]) == File.read(config[:dest]) out << "#{ok} file #{config[:dest].bold.blue } exists, and is up to date.\n" else FileUtils.cp(config[:source], config[:dest]) out << "#{ok} installing #{config[:dest].bold.blue }...\n" end out << if File.exist?(file) if File.read(file).include?(config[:script]) "#{ok} BASH script #{file.bold.yellow} already sources #{script_name.bold.blue}.\n" else append_completion_script(file, config[:script]) "#{ok} BASH script #{script_name.bold.blue} is now sourced from #{file.bold.yellow}\n" end else append_completion_script(file, config[:script]) "#{ok}, created new file #{file.bold.yellow}, added #{script_name.bold.blue} initialization.\n" end end out << "\nPlease reload your terminal session to activate bash completion\n" out << "and other installed BASH utilities.\n" out << "\nAlternatively, just type #{"source #{file}".bold.green} to reload BASH.\n" out << "Also — go ahead and try running #{'sym -h'.bold.blue} and #{'symit -h'.bold.blue}.\n" end |
#ok ⇒ Object
10 11 12 |
# File 'lib/sym/app/commands/bash_completion.rb', line 10 def ok ' '.bold.green end |