samg / timetrap

Simple command line timetracker
http://rubygems.org/gems/timetrap
Other
1.48k stars 116 forks source link

Select sheet based on `pwd` #69

Closed TSFoster closed 9 years ago

TSFoster commented 10 years ago

I'm pretty sure I'm going to do this for me anyway, but I just wanted to see if it was something you would pull if I sent a request.

I'd like to use specific sheets when I'm in certain directories. Say you want to use the sheet "Secret Project" when you're in ~/projects/secret/. Timetrap would work as usual everywhere else, but when you're running it from within ~/projects/secret/ it will check in to and out of "Secret Project".

I'm not quite sure how I'd do this yet, maybe a local .timetrap file with just the name of the sheet to use.

samg commented 10 years ago

I think this is a pretty cool feature idea. I can imagine how it would be very convenient for someone switching from various project directories and wanting to track time by project.

Using a per directory .timetrap seems like a reasonable approach. Another option might be to read a hash from the ~/.timetrap.yml so that users could t configure which directories map to which projects without having to put a dotfile in each project. You might also want to consider recursive logic (e.g. I organize my projects into directories by client and I want to log time against "Client A" when I'm in /code/client-a/project2).

Either way it seems like a really interesting idea and it would be great to see it developed to the point where it'd be generally useful.

vlcinsky commented 10 years ago

NIce idea, but be keep it simple and predictable from user point of view. I would rather not do things automatically (not telling you propose to do so), as one may just go somewhere in directory tree for one small file and could accidentally change sheet without being aware of it.

What about explicitly changing the current sheet by using a dot:

$ t sheet .

It would pick config for related sheet based on current or any closest parent directory and would print the picked sheet out, so that user knows, what he did (without questioning the user anyway).

And one more idea: when running "sheet" subcommand without any parameter, we could denote the sheet, which would be selected by current directory by a dot in front of it. As there could be already a mark ("*" or "-"), we coudl use one of following representations:

  1. add one extra column for printing the dot (not liking this idea much)
  2. print there two characters (the "." and the "*" or "-")
  3. omit the dot in such a case.

I would prefer the 2nd option

TSFoster commented 10 years ago

@vlcinsky I know what you mean, I considered the issue myself. I kind of think that if you're using a command line timetracking tool you're probably at least a "power user", so it shouldn't be too confusing. Also, you will have to explicitly add a setting to use a given sheet in a given directory, and when you check in and out, it tells you what sheet you're using. I guess there could also be a notice when you check in and out explaining it's switched sheets for you.

@samg Yes, I think it's useful for a sheet to be used in all descendent directories. I'm in two minds about using a local .timetrap file or an entry in .timetrap.yml. I like the idea that you can move your directories around and timetrap will still know which sheet to use (without having to change your settings in .timetrap.yml). But I also like the idea of using your existing config file, and not introducing a new mechanism.

courajs commented 9 years ago

@samg This issue can be closed as it's been implemented and merged in