Skip to content

Commit 34cc5f3

Browse files
committed
Add some reference material to work. [admin]
1 parent dfed51f commit 34cc5f3

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

work/reference/bash_completion.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+

work/sandbox/readme-example.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+

0 commit comments

Comments
 (0)