File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ # ~/.bash_completion.d/yaml_command
2+
3+ _yaml ()
4+ {
5+ local cur=${COMP_WORDS[COMP_CWORD]}
6+ local pos=(COMP_CWORD - 1)
7+ local pre=${COMP_WORDS[@]: 0: $pos }
8+ local cpl=$( $pre _)
9+
10+ if [[ " $cur " == -* ]]; then
11+ cpl=${cpl[@]// ^[^-]/ }
12+ else
13+ cpl=${cpl[@]// -*/ }
14+ fi
15+
16+ COMPREPLY=( $( compgen -W " $cpl " -- $cur ) )
17+ }
18+ complete -F _yaml yaml
19+
Original file line number Diff line number Diff line change 1+ require 'executable'
2+
3+ class HelloCommand
4+ include Executable
5+
6+ # Say it in uppercase?
7+ def loud = ( bool )
8+ @loud = bool
9+ end
10+
11+ #
12+ def loud?
13+ @loud
14+ end
15+
16+ # Show this message.
17+ def help!
18+ cli . show_help
19+ exit
20+ end
21+ alias :h! :help!
22+
23+ # Say hello.
24+ def call ( name = nil )
25+ name = name || 'World'
26+ str = "Hello, #{ name } !"
27+ str = str . upcase if loud?
28+ puts str
29+ end
30+ end
31+
32+ HelloCommand . execute
33+
You can’t perform that action at this time.
0 commit comments