-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some reference material to work. [admin]
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# ~/.bash_completion.d/yaml_command | ||
|
||
_yaml() | ||
{ | ||
local cur=${COMP_WORDS[COMP_CWORD]} | ||
local pos=(COMP_CWORD - 1) | ||
local pre=${COMP_WORDS[@]:0:$pos} | ||
local cpl=$($pre _) | ||
|
||
if [[ "$cur" == -* ]]; then | ||
cpl=${cpl[@]//^[^-]/} | ||
else | ||
cpl=${cpl[@]//-*/} | ||
fi | ||
|
||
COMPREPLY=( $(compgen -W "$cpl" -- $cur) ) | ||
} | ||
complete -F _yaml yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'executable' | ||
|
||
class HelloCommand | ||
include Executable | ||
|
||
# Say it in uppercase? | ||
def loud=(bool) | ||
@loud = bool | ||
end | ||
|
||
# | ||
def loud? | ||
@loud | ||
end | ||
|
||
# Show this message. | ||
def help! | ||
cli.show_help | ||
exit | ||
end | ||
alias :h! :help! | ||
|
||
# Say hello. | ||
def call(name=nil) | ||
name = name || 'World' | ||
str = "Hello, #{name}!" | ||
str = str.upcase if loud? | ||
puts str | ||
end | ||
end | ||
|
||
HelloCommand.execute | ||
|