/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-08-01 19:57:56 UTC
  • Revision ID: tim@ed.am-20120801195756-qaxahzf9sikcbv6e
removed --list option because it was confusing and unnecessary

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;
20
19
my $mode_help = 0;
21
20
my $mode_version = 0;
22
21
 
26
25
    'a|all' => \$display_all,
27
26
    'e|edit' => \$mode_edit,
28
27
    'h|headers' => \$display_headers,
29
 
        'l|list' => \$mode_less,
30
28
    's|section=s' => \$display_section,
31
29
    'help' => \$mode_help,
32
30
    'version' => \$mode_version,
44
42
    "  -a, --all              display all sections\n".
45
43
    "  -e, --edit             edit your todo file\n".
46
44
    "  -h, --headers          show setion headers\n".
47
 
        "  -l, --list             show the list in your pager (see notes)\n".
48
45
    "  -s, --section=SECTION  display sections matching the regular expression\n".
49
46
    "      --help     display this help and exit\n".
50
47
    "      --version  output version information and exit\n".
52
49
        "Running without any options is the same as running with --section=TODO and\n".
53
50
        "lists the default section of the todo file.\n".
54
51
        "\n".
55
 
        "The advantage of using '--list' is that the pager is run as if the\n".
56
 
        "todo list were being edited. This means that if you decide to spawn an\n".
57
 
        "editor from you pager and edit the list, these changes get noticed.\n".
58
 
        "\n".
59
 
        "The environment variables EDITOR and PAGER are used.\n".
 
52
        "The environment variables EDITOR is used.\n".
60
53
        "\n".
61
54
        "Please report bugs to Tim Marston <tim\@ed.am>.\n";
62
55
    exit( 0 );
82
75
$todo_dir = glob( $todo_dir );
83
76
( -f $todo_dir ) and die "$todo_dir exists and is a file";
84
77
 
85
 
# less mode
86
 
if( $mode_less )
87
 
{
88
 
    ( ! -f "$todo_dir/todo" ) && die "no todo file";
89
 
        $mode_edit = 1;
90
 
}
91
 
 
92
78
# edit mode
93
79
if( $mode_edit )
94
80
{
125
111
 
126
112
    # determine editor from environment, default to "emacs -nw"
127
113
        my $editor;
128
 
        if( $mode_less ) {
129
 
                $editor = $ENV{ 'PAGER' };
130
 
                defined $editor or $editor = 'less';
131
 
        }
132
 
        else {
133
 
                $editor = $ENV{ 'EDITOR' };
134
 
                defined $editor or $editor = 'emacs -nw';
135
 
        }
 
114
        $editor = $ENV{ 'EDITOR' };
 
115
        defined $editor or $editor = 'emacs -nw';
136
116
    my @exec_array = split( / +/, $editor );
137
117
    push( @exec_array, "$todo_dir/todo" );
138
118