App-Easer
view release on metacpan or search on metacpan
#!/usr/bin/env perl
use v5.24;
use warnings;
use experimental 'signatures';
no warnings 'experimental::signatures';
use App::Easer 'run';
my $application = {
factory => {prefixes => {'#' => 'TuDu#'}},
configuration => {
'auto-leaves' => 1,
'help-on-stderr' => 1,
},
commands => {
MAIN => {
help => 'to-do application',
description => 'A simple to-do application',
options => [
{
help => 'path to the configuration file',
getopt => 'config|c=s',
environment => 'TUDU_CONFIG',
},
{
help => 'base directory where tasks are kept',
getopt => 'basedir|dir|d=s',
environment => 'TUDU_BASEDIR',
default => "$ENV{HOME}/.tudu",
},
{
help => 'max number of attempts to find non-colliding id',
getopt => 'attempts|max-attempts|M=i',
default => 9,
},
],
sources => '+SourcesWithFiles',
'config-files' => ["$ENV{HOME}/.tudu.conf", '/etc/tudu.conf'],
commit => '#ensure_basedir',
children => [qw< list show cat add edit done wait resume remove >],
},
dump => { # this child is normally excluded!
help => 'dump configuration',
execute => sub ($m, $c, $a) {
require Data::Dumper;
warn Data::Dumper::Dumper({config => $c, args => $a});
return 0;
},
},
list => {
help => 'list tasks',
description => 'Get full or partial list of tasks',
supports => [qw< list ls >],
options => [
{
help => 'include all tasks (including done) '
. '(exclusion is not honored)',
getopt => 'all|A!',
},
{
help => 'include(/exclude) all active tasks '
. '(ongoing and waiting)',
getopt => 'active|a!',
},
{
help => 'include(/exclude) done tasks',
getopt => 'done|d!',
},
{
help => 'include(/exclude) ongoing tasks',
getopt => 'ongoing|o!',
},
{
help => 'include(/exclude) waiting tasks',
getopt => 'waiting|w!',
},
{
help => 'use extended, unique identifiers',
getopt => 'id|i!',
},
{
help => 'limit up to n items for each category (0 -> inf)',
getopt => 'n=i'
},
],
execute => '#list',
},
show => {
help => 'print one task',
description => 'Print one whole task',
supports => [qw< show print get >],
execute => '#show',
},
cat => {
help => 'print one task (no delimiters)',
description => 'Print one whole task, without adding delimiters',
supports => [qw< cat >],
execute => '#cat',
},
add => {
help => 'add a task',
description => 'Add a task, optionally setting it as waiting',
supports => [qw< add new post >],
options => [
{
help => 'add the tasks as waiting',
( run in 1.348 second using v1.01-cache-2.11-cpan-ceb78f64989 )