diff --git a/worktimer.scm b/worktimer.scm index d8ff22c..33f1785 100755 --- a/worktimer.scm +++ b/worktimer.scm @@ -103,7 +103,7 @@ (if (not path-end) #f (path-split str 0 path-end)))) (dates (substring/find str #\[ #\]))) - (if (or (not path) (not dates)) + (if (or (not path) (not dates) (null? dates)) #f (let ((date-start (string->date (car dates) date-time-format))) (let-values (((date-end duration) @@ -134,6 +134,63 @@ (define (read-timesheet filename) (read-and-parse-file filename parse-task-string)) +;;; Compare paths +(define (pathstring (car last)) - (time->string - (date-difference (current-date) (cadr last)))) - (format #t "NO TASKS\n"))) + ;; Show running task + (let ((last (last-task sheet))) + (if (and last (not (caddr last))) + (format #t "~a: ~a\n" + (path->string (car last)) + (time->string + (date-difference (current-date) (cadr last)))) + (format #t "NO TASKS\n"))) - ;; Else run command - (let ((param (cdr command)) - (command (car command))) - (let ((new-sheet - (apply (cond - ((string= command "start") cmd-start-task) - ((string= command "stop") cmd-stop-task) - ((string= command "report") cmd-report) - ((string= command "refresh") (lambda (s . p) s)) - ((string= command "tasklist") cmd-tasklist) - ((string= command "deadline") cmd-deadline) - - ;; ----------------------- Show usage ------------------------- ;; - (else - (with-output-to-port (current-error-port) - (lambda () - (format #t "Usage: ~a [command]\n" (car cmdl)) - (format #t "Commands:\n") - (format #t " start [TASK] Start new task. If no task, use last runned task\n") - (format #t " stop Stop task\n") - (format #t " report Show report\n") - (format #t " report day [DATE] Show report for today or DATE\n") - (format #t " report week [DATE] Show report for current week or week of DATE\n") - (format #t " report month [DATE] Show report for current month or month of DATE\n") - (format #t " report TASK Show report for project\n") - (format #t " deadline set [TASK] DATE|+TIME Add deadline for project (or for last task)\n") - (format #t " deadline clear [TASK] Remove deadline for project (or for last task)\n") - (format #t " deadline [TASK] Show deadline for project\n") - (format #t " deadline all Show all deadlines\n") - (format #t " refresh Refresh worksheet file after manual edit\n") - (format #t " (no command) Show running task and timer\n\n") - (format #t "DATE format: YYYY-mm-dd\n") - (format #t "TIME format: HH-MM-SS\n") - (newline))) - (lambda (s . p) #f))) - (cons sheet param)))) - - ;; ----------------------- Save new sheet ------------------------- ;; - (when (and - (list? new-sheet) - (not (null? new-sheet))) - (with-output-to-file ts-file - (lambda () - (print-timesheet new-sheet))))))))) + ;; Else run command + (let ((param (cdr command)) + (command (car command))) + (let ((new-sheet + (apply (cond + ((string= command "start") cmd-start-task) + ((string= command "stop") cmd-stop-task) + ((string= command "report") cmd-report) + ((string= command "refresh") (lambda (s . p) s)) + ((string= command "tasklist") cmd-tasklist) + ((string= command "deadline") cmd-deadline) + + ;; ----------------------- Show usage ------------------------- ;; + (else + (with-output-to-port (current-error-port) + (lambda () + (format #t "Usage: ~a [command]\n" (car cmdl)) + (format #t "Commands:\n") + (format #t " start [TASK] Start new task. If no task, use last runned task\n") + (format #t " stop Stop task\n") + (format #t " report Show report\n") + (format #t " report day [DATE] Show report for today or DATE\n") + (format #t " report week [DATE] Show report for current week or week of DATE\n") + (format #t " report month [DATE] Show report for current month or month of DATE\n") + (format #t " report TASK Show report for project\n") + (format #t " deadline set [TASK] DATE|+TIME Add deadline for project (or for last task)\n") + (format #t " deadline clear [TASK] Remove deadline for project (or for last task)\n") + (format #t " deadline [TASK] Show deadline for project\n") + (format #t " deadline all Show all deadlines\n") + (format #t " refresh Refresh worksheet file after manual edit\n") + (format #t " (no command) Show running task and timer\n\n") + (format #t "DATE format: YYYY-mm-dd\n") + (format #t "TIME format: HH-MM-SS\n") + (newline))) + (lambda (s . p) #f))) + (cons sheet param)))) + + ;; ----------------------- Save new sheet ------------------------- ;; + (when (and + (list? new-sheet) + (not (null? new-sheet))) + (with-output-to-file ts-file + (lambda () + (print-timesheet new-sheet)))))))))) ;;; JUST DO IT! -(main (command-line)) +;(main (command-line)) +