+elsif ( ( $command eq "activity") || ($command eq "task" ) )
+{
+ if ( $#ARGV < 1)
+ {
+ help(START);
+ }
+
+ my ( $start_time, $title ) = parse_arguments(START);
+
+ my $trk_id = get_current_id();
+ if ( not $trk_id )
+ {
+ printf("Starting a task/activity requires an active main track.\n");
+ exit(1);
+ }
+ else
+ {
+
+ my $current = get_current_id( $trk_id );
+ if ( not $current )
+ {
+ $current = start_track( $start_time, $title, $trk_id );
+
+ if ( not $current )
+ {
+ printf("Something weird happened.\n");
+ exit(1);
+ }
+ }
+ else
+ {
+ printf("A task/activity is being tracked: %s\n", get_track_name( $current, $trk_id ) );
+ close_track($start_time, $trk_id);
+ $current = start_track( $start_time, $title, $trk_id );
+ }
+
+ printf("Started tracking of '%s' at %s\n\n", $title, scalar localtime $start_time);
+
+ }
+
+}
+
+elsif ( $command eq "main" )
+{
+
+ if ( $#ARGV < 0)
+ {
+ help(STOP);
+ }
+
+
+ my $stop_time = parse_arguments(STOP);
+
+ my $trk_id = get_current_id();
+ if ( not $trk_id )
+ {
+ printf("Stopping a task/activity requires an active main track.\n");
+ exit(1);
+ }
+ else
+ {
+ my $current = get_current_id( $trk_id );
+ if ( not $current )
+ {
+ printf("No activity/task is currently tracked. To stop, please start first\n");
+ exit(0);
+ }
+ my $title = get_track_name( $current, $trk_id );
+ close_track($stop_time, $trk_id);
+
+ printf("Stopped tracking of '%s' at %s\n\n", $title, scalar localtime $stop_time);
+ }
+}