App-OrgUtils
view release on metacpan or search on metacpan
script/list-org-todo-states view on Meta::CPAN
our $DIST = 'App-OrgUtils'; # DIST
our $VERSION = '0.487'; # VERSION
our %SPEC;
$SPEC{list_org_todo_states} = {
v => 1.1,
summary => 'List all todo states in all Org files',
args => {
%App::OrgUtils::common_args1,
detail => {
schema => 'bool',
cmdline_aliases => {l=>{}},
},
done => {
summary => 'Only show done states',
'summary.alt.bool.not' => 'Only show undone states',
schema => 'bool',
tags => ['category:filtering'],
},
},
};
sub list_org_todo_states {
my %args = @_;
my $tz = $args{time_zone} // $ENV{TZ} // "UTC";
my %docs = App::OrgUtils::_load_org_files(
$args{files}, {time_zone=>$tz});
my @res;
my %seen;
for my $doc (values %docs) {
for (@{ $doc->todo_states }) {
next if $seen{$_}++;
next if $args{done};
if ($args{detail}) {
push @res, {state=>$_, is_done=>0};
} else {
push @res, $_;
}
}
for (@{ $doc->done_states }) {
next if $seen{$_}++;
next if defined($args{done}) && !$args{done};
if ($args{detail}) {
push @res, {state=>$_, is_done=>1};
} else {
push @res, $_;
}
}
}
my $resmeta = {};
if ($args{detail}) {
$resmeta->{'table.fields'} = [qw/state is_done/];
}
[200, "OK", \@res, $resmeta];
}
binmode STDOUT, ":encoding(utf8)";
Perinci::CmdLine::Any->new(url=>'/main/list_org_todo_states')->run;
1;
# ABSTRACT: List all todo states in all Org files
# PODNAME: list-org-todo-states
__END__
=pod
=encoding UTF-8
=head1 NAME
list-org-todo-states - List all todo states in all Org files
=head1 VERSION
This document describes version 0.487 of list-org-todo-states (from Perl distribution App-OrgUtils), released on 2024-01-09.
=head1 SYNOPSIS
=head1 OPTIONS
C<*> marks required options.
=head2 Main options
=over
=item B<--detail>, B<-l>
(No description)
=item B<--file>=I<s@>*
(No description)
Can also be specified as the 1st command-line argument and onwards.
Can be specified multiple times.
=item B<--files-json>=I<s>
See C<--file>.
Can also be specified as the 1st command-line argument and onwards.
=item B<--time-zone>=I<s>
Will be passed to parser's options.
If not set, TZ environment variable will be picked as default.
=back
=head2 Configuration options
( run in 0.868 second using v1.01-cache-2.11-cpan-39bf76dae61 )