Skip to content

Commit

Permalink
Add some reference material to work. [admin]
Browse files Browse the repository at this point in the history
  • Loading branch information
trans committed Feb 6, 2013
1 parent dfed51f commit 34cc5f3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
19 changes: 19 additions & 0 deletions work/reference/bash_completion.sh
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

33 changes: 33 additions & 0 deletions work/sandbox/readme-example.rb
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

0 comments on commit 34cc5f3

Please sign in to comment.