rakext
Lite and powerful rake extension.
Rakext allows you to create rake tasks by just writing methods. Besides, you can pass tasks arguments as ruby code, YAML or JSON strings and they will be evaluated as you expect.
Task Usage
You can define your own modules and include Rakext::Tasks
in order to create your tasks:
module MyTasks
include Rakext::Tasks
prefix 'my_pref:'
desc 'this is the my_pref:foo - args(opts)'
def foo(opts)
print 'received arguments: '
p opts
end
module NestedNamespace
include Rakext::Tasks
desc 'this is the my_task:nested_namespace:bar - args(a,b,c)'
def bar(a, b, c)
print 'received arguments: '
p a, b, c
end
end
end
In the Rakefile:
require 'rakext'
require 'my_tasks'
Check the tasks:
$ rake -T
rake my_pref:foo
rake my_tasks:nested_namespace:bar
CLI Usage
A few examples about passing args:
$ rake my_pref:foo RUBY_ARGS='a:"foo", b: "bar"'
$ rake my_task:nested_namespace:bar RUBY_ARGS='{a:4,b:3}, "a", "b"'
$ rakext my_pref:foo YAML_ARGS='
---
:a: foo
:b: bar
'
$ rakext my_task:nested_namespace:bar JSON_ARGS='
[{"a":4,"b":3}, "a", "b"]
'
Try it
Look at the 2 files in test to see how it works. You may also run . text.sh
to try it.
Tips and tricks
Since the rakext
bin is exactly the same rake
bin with just an added m
multiline flag, you can symlink it so you will always use rakext
when you type rake
.
Copyright
Copyright (c) 2012 by Domizio Demichelis
See LICENSE for details.