Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add switch command that stops a running timer and starts a new timer #74

Closed
Pokerkoffer opened this issue May 1, 2021 · 4 comments
Closed
Labels
ENHANCEMENT Ideas and feature requests

Comments

@Pokerkoffer
Copy link

Pokerkoffer commented May 1, 2021

Hi,
first of all great tool, I think plain text as database is heavily underrated and a huge pro for considering to use klog.

As I am working on different projects per day, it would be convenient if I can simply stop tracking time for the current project and start tracking time for another project.

Currently the following steps are necessary to switch from one timer to another:

# start working on project A
$ klog start a.klog

# ...

# oops, a bug report of project B came in and must be addressed immediately
$ klog stop a.klog

# start working on bugfix
$ klog start -s "bugfix #123" b.klog

# ...

# implementation of bugfix finished
$ klog stop b.klog

# resume work on projectA
$ klog start b.klog

A simple klog switch 2.klg would simplify this workflow.

However, additional work and clarification is needed:

  • klog needs to keep track of running timers because it must stop them.
    Possible solution: klog maintains a running timers file (e.g. /home/$user/.klog where the path to the .klg file is added when the timer starts and removed when the timer is stopped
  • What to do when multiple timers are currently running?
    • stop only most recently started timer
    • stop all timers
    • let user choose.

Edit:
Another possibility that arises from keeping track of running timers is that you easily query a list of running timers.
For instance something like that:

$ klog status

Running timers:
+------------------+-------------+----------------+---------------+
|      Start       | Running for |  Description   |     File      |
+------------------+-------------+----------------+---------------+
| 2021-04-01 08:00 |    00:04:22 | Bugfix #1337   | project_a.klg |
| 2021-03-15 10:22 |    15:04:00 | Implement Task | project_b.klg |
+------------------+-------------+----------------+---------------+

However klog can only display the status for timers that have been started with klog. Maybe time sheets can be registered at klog, for keeping track of them (or entire directories)?

But that would be another task :)

Thanks!
Regards

@jotaen
Copy link
Owner

jotaen commented May 1, 2021

Thanks for your feedback and detailed suggestions! 🎉

The closest to something like “projects” is currently the bookmark subcommand. It’s quite simple at the moment, though, because it’s really just a symlink under the hood. Its primary use-case is if you have a single ongoing file e.g. for the current month or some other period of time. That can be quite limiting, so I think the bookmark functionality would be worth to enhance a bit:

  • In order to be more flexible, klog should support multiple bookmarks and not just one. E.g., it could keep an internal history of previous bookmarks, so that it’s more convenient to switch back and forth between them.
  • Based on this it could be useful to name the bookmarks, along the lines of:
    klog bookmark save --name="project1" /home/myself/project-1/2021/04.klg
    Then you could do:
    klog bookmark switch project1
    and you don’t have to juggle with file names anymore.
  • That being said, there should still be a default bookmark, so that people don’t have to bother with multiple ones if they don’t need that.

Regarding the idea of “projects” (and adding more functionality around that) I unfortunately have to say I think it’s out of scope for integrating into the core of klog. The way people organise their files is subject to very individual workflows. In the spirit of UNIX (“do one thing, do it well”) my current thinking is to make/keep klog as generic tool for interacting with .klg files and nothing more, but at the same time to support users as best as possible to build their own things around it according to their individual needs. So in your case – assuming the bookmarks were a bit more powerful – I could imagine it being possible to encode your suggested workflow in a few lines of bash script, that uses klog commands under the hood.

@jotaen
Copy link
Owner

jotaen commented Oct 5, 2021

A switch functionality is out of scope for klog, unfortunately. Below is an idea, though, how such a workflow could be made happen.

The next release will add support for multiple bookmarks, as briefly illustrated here. (The docs will also be updated with more info after the release.) Based on that, users could write a shell script that achieves the same effect and can be customised to their own workflow. E.g.:

klog-switch -s "Do something" @project3

  1. Run klog bookmarks list and grep the output for the current bookmark names
  2. For each bookmark, run klog stop
  3. Invoke klog start and pass through the original arguments (here, -s "Do something" @project3)

@jotaen jotaen closed this as completed Oct 5, 2021
@the-solipsist
Copy link

Time permitting, it might be helpful if there was a "contribs" directory with examples of simple scripts like this, so people know that workflows like this are possible.

@jotaen
Copy link
Owner

jotaen commented Apr 14, 2022

The “extending” section of the documentation website roughly covers this, but it’s more of a general overview. If I have time, I might add a more concrete example there, to illustrate the possibilities better.

I’m also happy to link tools or helper scripts made by other users, by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ENHANCEMENT Ideas and feature requests
Projects
None yet
Development

No branches or pull requests

3 participants