From: Jon Langseth Date: Tue, 14 May 2013 12:19:41 +0000 (+0200) Subject: Added listing of tasks/activities X-Git-Url: https://git.defcon.no/?a=commitdiff_plain;p=trk Added listing of tasks/activities --- diff --git a/README.txt b/README.txt index 0b36b7a..2f3520b 100644 --- a/README.txt +++ b/README.txt @@ -60,7 +60,7 @@ trk list [verbose] trk projects [verbose] Lists all known project names. If a project/track is currently - active, thata project will be indicated with a chevron (>). + active, that project will be indicated with a chevron (>). Adding verbose to the command will display ID hashes along with the project/track names. @@ -83,6 +83,15 @@ trk main at Stops tracking ongoing activity, and keeps tracking project. +trk tasks [verbose] +trk activities [verbose] + + Lists all known task/activity names for current project/track. + If a given sub-task/activity is currently active, that project + will be indicated with a chevron (>). + Adding verbose to the command will display ID hashes along + with the activity/task names. + trk status Displays current project, charged customer (if any), diff --git a/trk b/trk index c39e02b..6629a7c 100755 --- a/trk +++ b/trk @@ -571,6 +571,7 @@ elsif ( $command eq "main" ) printf("Stopped tracking of '%s' at %s\n\n", $title, scalar localtime $stop_time); } } +#### Mark elsif ( ( $command eq "projects" ) || ( $command eq "list" ) ) { # Todo/future extensions: @@ -596,6 +597,45 @@ elsif ( ( $command eq "projects" ) || ( $command eq "list" ) ) } print("\n"); } +#### Mark +elsif ( ( $command eq "activities" ) || ( $command eq "tasks" ) ) +{ + # Todo/future extensions: + # TODO: Sort list of names alphabetically + # TODO: Get total-hours for projects + # TODO: + + + my $trk_id = get_current_id(); + if ( not $trk_id ) + { + printf("Starting a task/activity requires an active main track.\n"); + exit(1); + } + + my $verbose = (( $#ARGV >= 1) && ( $ARGV[1] eq "verbose" )); + + my $tracks = get_tracks( $trk_id ); + printf("Current track is '%s'\n", get_track_name( $trk_id )); + printf("Track ID for for current track is %s\n", $trk_id) if $verbose; + printf("Currently tracked activities/tasks for track '%s':\n\n", get_track_name( $trk_id )); + my $current = get_current_id( $trk_id ); + + #foreach my $id ( keys %$tracks ) + foreach my $id ( sort { $tracks->{$a} cmp $tracks->{$b} || $a cmp $b } keys %$tracks ) + { + + if ( $verbose ) + { + printf(" %s %s %s\n", ($id eq $current ? ">" : " " ), $id , $tracks->{$id}); + } + else + { + printf(" %s %s\n", ($id eq $current ? ">" : " " ),$tracks->{$id} ); + } + } + print("\n"); +} elsif ( $command eq "report" ) {