adeel / timed

a command-line time tracker
adeel.github.com/timed
MIT License
109 stars 13 forks source link

`timed start foo` does not stop the currently active project #14

Open seanh opened 9 years ago

seanh commented 9 years ago

In the example below I:

  1. Start working on foo
  2. After two minutes, start working on bar (I would expect this to implicitly stop working on foo)
  3. After one minute, stop working on bar
  4. Wait one minute then do timed summary

I would expect timed summary to report 2 minutes worked on foo and 1 minute on bar. In fact it reports 1 minute on bar and 4 minutes on foo. The time recorded against foo will just keep increasing now as time goes by, there's no way to stop it (except editing ~/.timed manually).

Looking at ~/.timed, there's no end time for when I was working on foo, and evidently timed doesn't consider the start time for bar on the following line to be an end time for foo. Timed considers that foo is still running. timed stop does not stop foo from running.

You're now in a broken state that the timed cli doesn't seem able to get out of. Only editing ~/.timed manually can fix it.

Is this intentional - are you supposed to always do timed stop before doing timed foo?

I'd call this a bug - doing timed start ... when there's a currently active project should implicitly stop the active project. You wouldn't even have to change what gets written to ~/.timed, just change timed summary so that if a ~/.timed line doesn't have an end time then the start time on the next line is considered as its end time (unless there is no next line, in which case it's the active project).

seanh@mistakenot ~ cat .timed
seanh@mistakenot ~ timed start foo
starting work on foo
  at 17:54 on 17 Mar 2015
seanh@mistakenot ~ timed start bar
starting work on bar
  at 17:56 on 17 Mar 2015
seanh@mistakenot ~ timed stop
worked on bar
  from    17:56 on 17 Mar 2015
  to now, 17:57 on 17 Mar 2015
       => 0h1m elapsed
seanh@mistakenot ~ cat .timed
foo: 17:54 on 17 Mar 2015 - 
bar: 17:56 on 17 Mar 2015 - 17:57 on 17 Mar 2015⏎
seanh@mistakenot ~ timed summary
bar   0h1m
foo   0h4m
seanh@mistakenot ~ timed stop
worked on bar
  from    17:56 on 17 Mar 2015
  to now, 17:57 on 17 Mar 2015
       => 0h1m elapsed
seanh@mistakenot ~ cat .timed
foo: 17:54 on 17 Mar 2015 - 
bar: 17:56 on 17 Mar 2015 - 17:57 on 17 Mar 2015⏎
adeel commented 9 years ago

Thanks for reporting. The intended usage is to run timed stop before timed starting a new project. I think a good solution to this problem would be to allow to specify an argument to timed stop. As I don't use timed actively anymore, I will not be fixing this, but I would accept a pull request that does.