ACME-2026
view release on metacpan or search on metacpan
lib/ACME/2026.pm view on Meta::CPAN
(C<YYYY-MM-DD> or C<YYYY-MM-DDTHH:MM:SSZ>).
=head1 FUNCTIONS
=head2 plan_new
my $plan = plan_new(%opts);
Creates a new plan hashref. Supported options:
title - plan title (default: 2026)
storage - JSON path used by plan_save and autosave
autosave - boolean, save after mutating operations
=head2 plan_load
my $plan = plan_load($path, %opts);
Loads a JSON file from C<$path>. The plan is normalized to ensure required
fields exist. You can override C<title> or C<autosave> with C<%opts>.
script/acme2026 view on Meta::CPAN
if ($msg) {
warn "$msg\n";
}
print <<'USAGE';
Usage:
acme2026 add "Title" [--list NAME] [--tag TAG ...] [--priority N] [--due YYYY-MM-DD] [--note TEXT] [--file PATH]
acme2026 complete ID [--note TEXT] [--file PATH]
acme2026 list [--status todo|done|skipped] [--list NAME] [--tag TAG ...] [--sort FIELD] [--file PATH]
Options:
--file, -f Path to JSON storage (default: 2026.json or $ACME_2026_FILE)
--sort One of: due, -due, priority, -priority, created, updated, title, -title
--help, -h Show this help
USAGE
exit($msg ? 1 : 0);
}
sub default_file {
return $ENV{ACME_2026_FILE} || '2026.json';
}
sub load_plan {
my ($path) = @_;
return -e $path ? plan_load($path) : plan_new(storage => $path);
}
my $cmd = shift @ARGV || '';
usage() if $cmd eq '' || $cmd eq 'help' || $cmd eq '--help' || $cmd eq '-h';
if ($cmd eq 'add') {
my $file = default_file();
my ($list, $priority, $due, $note, $help);
my @tags;
GetOptionsFromArray(
\@ARGV,
'file|f=s' => \$file,
'list|l=s' => \$list,
'tag|t=s@' => \@tags,
'priority|p=i' => \$priority,
'due|d=s' => \$due,
'note|n=s' => \$note,
script/acme2026 view on Meta::CPAN
$opts{note} = $note if defined $note;
$opts{tags} = \@tags if @tags;
my $id = add_item($plan, $title, %opts);
plan_save($plan, $file);
print "Added [$id] $title\n";
exit 0;
}
if ($cmd eq 'complete') {
my $file = default_file();
my ($note, $help);
GetOptionsFromArray(
\@ARGV,
'file|f=s' => \$file,
'note|n=s' => \$note,
'help|h' => \$help,
) or usage('Invalid options for complete');
usage() if $help;
my $id = shift @ARGV;
script/acme2026 view on Meta::CPAN
die "Plan file not found: $file\n" unless -e $file;
my $plan = plan_load($file);
complete_item($plan, $id, (defined $note ? (note => $note) : ()));
plan_save($plan, $file);
print "Completed [$id]\n";
exit 0;
}
if ($cmd eq 'list') {
my $file = default_file();
my ($status, $list, $sort, $help);
my @tags;
GetOptionsFromArray(
\@ARGV,
'file|f=s' => \$file,
'status|s=s' => \$status,
'list|l=s' => \$list,
'tag|t=s@' => \@tags,
'sort=s' => \$sort,
'help|h' => \$help,
t/01-functional.t view on Meta::CPAN
tags => ['fitness'],
priority => 2,
due => '2026-10-01',
);
my $id2 = add_item($plan, 'Publish a book', list => 'Work', tags => ['writing']);
is($id1, 1, 'first id');
is($id2, 2, 'second id');
my $item = get_item($plan, $id1);
is($item->{status}, 'todo', 'default status');
is($item->{list}, 'Health', 'list stored');
complete_item($plan, $id1, note => 'Signed up');
$item = get_item($plan, $id1);
is($item->{status}, 'done', 'completed');
is(scalar @{ $item->{notes} }, 1, 'note added');
my @todo = items($plan, status => 'todo');
is(scalar @todo, 1, 'todo filter');
( run in 1.741 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )