Class: Sym::App::Commands::BashCompletion
Constant Summary
Constants included
from Sym
BASH_COMPLETION, COMPLETION_FILE, COMPLETION_PATH, DESCRIPTION, ENV_ARGS_VARIABLE_NAME, LOGGER, NIL_LOGGER, VERSION
Instance Method Summary
collapse
Instance Method Details
#append_completion_script(file) ⇒ Object
30
31
32
33
34
|
# File 'lib/sym/app/commands/bash_completion.rb', line 30
def append_completion_script(file)
File.open(file, 'a') do |fd|
fd.write(Sym::BASH_COMPLETION[:script])
end
end
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/sym/app/commands/bash_completion.rb', line 10
def execute
install_completion_file
file = opts[:bash_completion]
if File.exist?(file)
if File.read(file).include?(Sym::BASH_COMPLETION[:script])
"#{'Hmmm'.bold.yellow}: #{file.bold.yellow} had completion for #{'sym'.bold.red} already installed\n"
else
append_completion_script(file)
"#{'OK'.bold.green}: appended completion for #{'sym'.bold.red} to #{file.bold.yellow}\n"
end
else
append_completion_script(file)
"#{'OK'.bold.green}: created new file #{file.bold.yellow} and installed BASH completion for #{'sym'.bold.red}\n"
end
end
|
#install_completion_file ⇒ Object