Haven't Blogged in a While...
... anyway, .. so today, this 11th day of the month of showers, April, 2012 the year of our Lord (take your pick), ... I've released my latest Kracken on the world.
World, meet Command::Do!
... anyway, .. so today, this 11th day of the month of showers, April, 2012 the year of our Lord (take your pick), ... I've released my latest Kracken on the world.
World, meet Command::Do!
Seems interesting! Is it feasible/easy to set up a system with subcommands a-la git?
I would suggest to write the examples with fully expanded keywords (field instead of fld, method instead of mth, ...), it might save you a few keystroke but they definitely don't help the casual reader. I wouldn't be a big fan of these abbreviation in any code handed over to me too, but that's probably personal taste.
Flavio, good point with regards to the keyword usage. Making a change. Thanks.
-Al
#!/usr/bin/env perl
package Twit;
use Command::Do;
fld command => {
required => 1,
min_length => 2,
filters => ['trim', 'strip', sub { $_[0] =~ s/\W/\_/g; $_[0] }]
};
mth run => {
input => ['command'],
using => sub {
my ($self) = @_;
print "Executing twit command ", $self->command, "\n"
}
};
package main;
Twit->new(params => { command => shift @ARGV })->run;
1;