Class: Tomo::Commands::CompletionScript

Inherits:
Object
  • Object
show all
Defined in:
lib/tomo/commands/completion_script.rb

Class Method Summary collapse

Class Method Details

.parse(_argv) ⇒ Object



6
7
8
9
10
11
12
13
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
# File 'lib/tomo/commands/completion_script.rb', line 6

def self.parse(_argv)
  puts "    # TOMO COMPLETIONS FOR BASH\n    #\n    # Assuming tomo is in your PATH, you can install tomo bash completions by\n    # adding this line to your .bashrc:\n    #\n    #   eval \"$(tomo completion-script)\"\n    #\n    # The eval technique is a bit slow but ensures bash is always using the\n    # latest version of the tomo completion script.\n    #\n    # Alternatively, you can copy and paste the current version of the script\n    # into your .bashrc. The full script is listed below.\n\n    _tomo_complete() {\n      local cur=\"${COMP_WORDS[COMP_CWORD]}\"\n      local prev=\"${COMP_WORDS[COMP_CWORD-1]}\"\n\n      if [[ $prev == \"-c\" || $prev == \"--config\" ]]; then\n        COMPREPLY=($(compgen -f -- ${cur}))\n        return 0\n      fi\n\n      if [[ \"${COMP_LINE: -1}\" == \" \" ]]; then\n        command=${COMP_LINE/tomo/tomo --complete}\n      else\n        command=${COMP_LINE/tomo/tomo --complete-word}\n      fi\n\n      suggestions=$($command)\n      local IFS=$'\\n'\n      COMPREPLY=($suggestions)\n      return 0\n    }\n\n    complete -o nospace -F _tomo_complete tomo\n\n  SCRIPT\nend\n"