git-time-metric / gtm

Simple, seamless, lightweight time tracking for Git
MIT License
973 stars 52 forks source link

Support tracking apps #98

Closed desaroger closed 5 years ago

desaroger commented 5 years ago

I wrote an issue (#96) some days ago, and this PR is my attempt to implement it myself. This is my first time programming in Go, so any help/advice will be appreciated, no hard feelings, be honest haha

Summary

So, basically I added the option --app to the record command, which indicates that the string passed is not a file, but an app name. Then it creates (if does not exists yet) the file .gtm/{appName}.app and tracks a simple event to that file. It's basically the same as the way the terminal was implemented, but for any app.

Also, added the option --app-off to some other commands, mimicking the --terminal-off behaviour.

What about terminal support

My idea was to try to "remove" the code related with the terminal support, but make the new code to work for the terminal in the exact same way. I did this for the templates, for the record command, etc. However I keep all the command flags, so everything keeps working as before for the terminal.

I wanted to add a "deprecated" warning when using the terminal flags, but I think is not my decision. Though I think the new app support makes the terminal flags to not make a lot of sense (my opinion).

You can mimic the terminal record command gtm record -terminal with the more generic flag gtm record -app terminal. It does exactly the same thing. I even changed the implementation of the former as an alias of the latter.

Tests

I added some test cases, basically where there were tests for terminal support. Everyhing builds and pass the tests for me, but the lint tests (make lint) throws lots of warnings. But I think is a problem of my Go setup, because those warning were thrown even with a clean cloned repo.

Things changed

I tried my best to not change anything of the current behavior, and unless I did something wrong, the only things that have been change:

I hope I didn't made some big mistake. I will change anything if you see a better way of doing it.

Thanks!

coveralls commented 5 years ago

Coverage Status

Coverage increased (+1.2%) to 65.178% when pulling 6e8c12bcdf4b9fc314977af9a44e8269564b9564 on desaroger:feature/support-tracking-apps into 8e616f8ae930617ab5b126ffd553f5e9e144df60 on git-time-metric:master.

mschenk42 commented 5 years ago

Thanks for the PR @desaroger. This looks pretty good. I'll give this a more thorough review by the end of the week.