-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtask.pl
executable file
·104 lines (89 loc) · 3.12 KB
/
rtask.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env perl
use strict;
use warnings;
use autodie;
use FindBin; # locate this script
use lib "$FindBin::Bin/lib";
#use lib './lib/';
use taskparse;
use File::Slurp 'read_file';
use Data::Printer;
use Capture::Tiny ':all';
use Text::Diff;
use Getopt::Long;
use Test::More;
#use Data::Dumper;
#$Data::Dumper::Deepcopy = 1; # for better dumps
#---------------------------------------------------------------------------
#--- utility subs
#---------------------------------------------------------------------------
sub printarray {
my $array = shift ;
foreach my $matchtag ( @{$array} ) { print " $matchtag"; }
print "\n";
}
sub selftest {
my @tasklist=rtget_tasklist();
#print "TASKLIST::\n".Dumper(@tasklist);
foreach my $titem (@tasklist)
{
#my $line = sprintf ("%3d",$titem->{'inputline'});
my $line = sprintf ("%d",$titem->{'inputline'});
my $spaces = "";
my $tags = join(" ", keys $titem);
$tags =~ s/inputline\s?//;
printf "$line: $tags";
if ( exists $titem->{'tags'} ) { print " (with ".@{$titem->{'tags'}}." tags)"; }
print "\n";
if ( exists $titem->{'text'} ) { print "$spaces text: $titem->{'text'}\n"; }
#else { print "$spaces text: <no task text found!>\n"; }
if ( exists $titem->{'qtext'} ) { print "$spaces qtext: $titem->{'qtext'}\n"; }
if ( exists $titem->{'comment'} ) { print "$spaces comment: $titem->{'comment'}\n"; }
if ( exists $titem->{'tags'} ) {
if (my @matched = grep( /\+/, @{$titem->{'tags'}}))
{ print "$spaces PROJ:"; printarray(\@matched); }
if (my @matched = grep( /\#/, @{$titem->{'tags'}}))
{ print "$spaces TAGS:"; printarray(\@matched); }
if (my @matched = grep( /\@/, @{$titem->{'tags'}}))
{ print "$spaces SCOP:"; printarray(\@matched); }
if (my @matched = grep( /\!/, @{$titem->{'tags'}}))
{ print "$spaces PRIO:"; printarray(\@matched); }
if (my @matched = grep( /\&/, @{$titem->{'tags'}}))
{ print "$spaces TYPE:"; printarray(\@matched); }
}
}
}
#---------------------------------------------------------------------------
#--- main
#---------------------------------------------------------------------------
#
# todo: CONFIG FILE
# http://search.cpan.org/~shlomif/Config-IniFiles-2.88/lib/Config/IniFiles.pm
# https://www.roaringpenguin.com/products/remind
# http://todotxt.com/
#
my $test=0;
my $infile="todo.txt";
GetOptions ('test' => \$test, 'infile=s' => \$infile);
if (@ARGV > 0) { $infile = shift @ARGV; }
if (@ARGV > 0) { die "ERROR: ".@ARGV." extra arguments on command line: @ARGV\n"; }
#print @INC;
my $g = rtinit_grammar();
my $r = rtinit_parser($g);
#p $g;
#p $r;
my $string;
if ( $test ) {
print "Use prove task-test.t ...\n";
}
else {
print "---Reading input from $infile...\n";
$string = read_file($infile);
}
print "---Parsing Input file with parser...\n";
$r->read(\$string);
print "---Retrieving the tree...\n";
my $tree = ${$r->value};
#print "Tree:\n".Dumper($tree);
#p $tree;
print "---DONE processing input\n";