This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
thor /
| name | age | message | |
|---|---|---|---|
| |
.autotest | Wed May 07 19:28:50 -0700 2008 | [wycats] |
| |
LICENSE | Tue May 06 19:21:22 -0700 2008 | [wycats] |
| |
README.markdown | Wed May 07 13:06:21 -0700 2008 | [wycats] |
| |
Rakefile | Mon May 12 18:19:18 -0700 2008 | [wycats] |
| |
bin/ | Mon May 12 18:19:18 -0700 2008 | [wycats] |
| |
lib/ | Mon May 12 18:19:18 -0700 2008 | [wycats] |
| |
script/ | Tue May 06 19:21:22 -0700 2008 | [wycats] |
| |
spec/ | Wed May 07 19:28:50 -0700 2008 | [wycats] |
| |
task.thor | Mon May 12 18:19:18 -0700 2008 | [wycats] |
README.markdownTypes for
:boolean
true if the option is passed
:required
A key/value option that MUST be provided
:optional
A key/value option that MAY be provided
thor
Map options to a class. Simply create a class with the appropriate annotations, and have options automatically map to functions and parameters.
Examples:
class MyApp
extend Hermes # [1]
map "-L" => :list # [2]
desc "install APP_NAME", "install one of the available apps" # [3]
method_options :force => :boolean # [4]
def install(name, opts)
... code ...
if opts[:force]
# do something
end
end
desc "list [SEARCH]", "list all of the available apps, limited by SEARCH"
def list(search = "")
# list everything
end
end
MyApp.start
Hermes automatically maps commands as follows:
app install name --force
That gets converted to:
MyApp.new.install("name", :force => true)
[1] Use extend Hermes to turn a class into an option mapper
[2] Map additional non-valid identifiers to specific methods. In this case, convert -L to :list
[3] Describe the method immediately below. The first parameter is the usage information, and the second parameter is the description.
[4] Provide any additional options. These will be marshaled from -- and - params. In this case, a --force and a -f option is added.




