[rex-users] Rex 0.37.2

  • From: Jan Gehring <jan.gehring@xxxxxxxxx>
  • To: rex-users@xxxxxxxxxxxxx
  • Date: Wed, 16 Jan 2013 22:28:57 +0100

Hi all,

i've just released Rex 0.37.2. This fixes a bug (
https://github.com/krimdomu/Rex/issues/89) that was accidentally commited
in Rex 0.35.

This is a feature that should be only active if a special feature flag
(flag: 0.35) is set.

This feature automatically converts the given parameters to a hash
reference if the task is called like a normal perl function.

If you write a task and need parameters please always use a hash reference
for the first parameter, because this is the way Rex calls a task if it
executes it via command line.

For example:

task "one", sub {
   my $param = shift;
   # $param is now a hash reference containing all the command line
parameters for a task.

bash# rex one --name=foo --bar=baz --something=nothing

You can now access these parameters with the $param hash reference.

task "one", sub {
   my $param = shift;
   say "name is: " . $param->{name};
   say "bar is: " . $param->{bar};
   say "something is: " . $param->{something};

And if you want to call the task like a perl function you can do it this

task "two", sub {
      name => "foo",
      bar  => "baz",
      something => "nothing",

With the "0.35" feature enabled you can also call it that way:

task "two", sub {
   one(name => "foo",
       bar  => "baz",
       something => "nothing");

If you just want to write a function with own custom parameters please use
the perl "sub {}" for it. So it didn't get accidentally called via command

sub myfunc {
   my $param1 = shift;
   my $param2 = shift;

   say "param1: $param1";
   say "param2: $param2";

task "two", sub {
   myfunc("first-param", "second-param");

Other related posts:

  • » [rex-users] Rex 0.37.2 - Jan Gehring