/todo

To get this branch, use:
bzr branch http://bzr.ed.am/todo

« back to all changes in this revision

Viewing changes to todo

  • Committer: edam
  • Date: 2012-03-12 14:07:28 UTC
  • Revision ID: tim@ed.am-20120312140728-nv11dg8zapxs9gtj
added --list

Show diffs side-by-side

added added

removed removed

16
16
my $display_section = "TODO";
17
17
my $display_headers = 0;
18
18
my $mode_edit = 0;
 
19
my $mode_less = 0;
19
20
my $mode_help = 0;
20
21
my $mode_version = 0;
21
22
 
25
26
    'a|all' => \$display_all,
26
27
    'e|edit' => \$mode_edit,
27
28
    'h|headers' => \$display_headers,
 
29
        'l|list' => \$mode_less,
28
30
    's|section=s' => \$display_section,
29
31
    'help' => \$mode_help,
30
32
    'version' => \$mode_version,
41
43
    "  -a, --all              display all sections\n".
42
44
    "  -e, --edit             edit your todo file\n".
43
45
    "  -h, --headers          show setion headers\n".
 
46
        "  -l, --list             show the list in your pager (see notes)\n".
44
47
    "  -s, --section=SECTION  display this named section\n".
45
48
    "      --help     display this help and exit\n".
46
 
    "      --version  output version information and exit\n";
 
49
    "      --version  output version information and exit\n".
 
50
        "\n".
 
51
        "The advantage of using '--list' is that the pager is run as if the\n".
 
52
        "todo list were being edited. This means that if you decide to spawn an\n".
 
53
        "editor from you pager and edit the list, these changes get noticed.\n".
 
54
        "\n".
 
55
        "The environment variables EDITOR and PAGER are used.\n".
 
56
        "\n".
 
57
        "Please report bugs to Tim Marston <tim\@ed.am>.\n";
47
58
    exit( 0 );
48
59
}
49
60
 
50
61
# version mode
51
62
if( $mode_version ) {
52
63
    print "todo 1.0\n".
53
 
        "Copyright (C) 2011 Tim Marston.\n".
 
64
        "Copyright (C) 2011, 2012 Tim Marston.\n".
54
65
        "http://ed.am/software/todo\n";
55
66
    exit( 0 );
56
67
}
67
78
$todo_dir = glob( $todo_dir );
68
79
( -f $todo_dir ) and die "$todo_dir exists and is a file";
69
80
 
 
81
# less mode
 
82
if( $mode_less )
 
83
{
 
84
    ( ! -f "$todo_dir/todo" ) && die "no todo file";
 
85
        $mode_edit = 1;
 
86
}
 
87
 
70
88
# edit mode
71
89
if( $mode_edit )
72
90
{
102
120
    }
103
121
 
104
122
    # determine editor from environment, default to "emacs -nw"
105
 
    my $editor = $ENV{ 'EDITOR' };
106
 
    defined $editor or $editor = 'emacs -nw';
 
123
        my $editor;
 
124
        if( $mode_less ) {
 
125
                $editor = $ENV{ 'PAGER' };
 
126
                defined $editor or $editor = 'less';
 
127
        }
 
128
        else {
 
129
                $editor = $ENV{ 'EDITOR' };
 
130
                defined $editor or $editor = 'emacs -nw';
 
131
        }
107
132
    my @exec_array = split( / +/, $editor );
108
133
    push( @exec_array, "$todo_dir/todo" );
109
134