AuHau / toggl-cli

A simple command-line interface for toggl.com

Home Page:https://toggl.uhlir.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Show sum of the current day

tbrodbeck opened this issue · comments

commented

Is there a way to show the sum of the current day with this tool?
toggle ls is nice. But I would like to have it summed up like the toggle desktop app does for the current day.
Screenshot 2020-04-16 at 15 52 34

Originally posted by @tbrodbeck in #133 (comment)

commented

Hey! I actually created a function for that right now.
Additionally it is capable to be used as a timer:
The functionality has the ability to setup a “goal” amount of hours for a day - the hours that you want/have to work that day. For example 8 hours every weekday.
Then I get a notification when my work is done.

I will do some testing on this code and then I will create you a PR :)

Interesting! Looking forward to PR :)

commented

I do not really understand how to run the files from the repository with python

$ python toggl/__main__.py
Traceback (most recent call last):
  File "toggl/__main__.py", line 4, in <module>
    from toggl.toggl import main
  File "/Users/t/Documents/toggl-cli/toggl/toggl.py", line 3, in <module>
    from toggl import cli
ImportError: cannot import name 'cli' from 'toggl' (/Users/t/Documents/toggl-cli/toggl/toggl.py)

And most of my pytests fail.

---------- coverage: platform darwin, python 3.7.6-final-0 -----------
Name                        Stmts   Miss  Cover
-----------------------------------------------
toggl/__init__.py               4      0   100%
toggl/__main__.py               4      4     0%
toggl/api/__init__.py           1      0   100%
toggl/api/base.py             306    189    38%
toggl/api/fields.py           414    264    36%
toggl/api/models.py           277    146    47%
toggl/cli/__init__.py           1      0   100%
toggl/cli/commands.py         476    229    52%
toggl/cli/helpers.py           98     86    12%
toggl/cli/types.py            136     92    32%
toggl/exceptions.py            32      3    91%
toggl/toggl.py                  7      1    86%
toggl/utils/__init__.py         2      0   100%
toggl/utils/bootstrap.py       88     64    27%
toggl/utils/config.py         185     61    67%
toggl/utils/metas.py           38     10    74%
toggl/utils/migrations.py      92     64    30%
toggl/utils/others.py         102     61    40%
-----------------------------------------------
TOTAL                        2263   1274    44%

=============================================== 2 deselected, 20 error in 3.67 seconds ================================================
✘~/Documents/toggl-climasterpython toggl/__main__.py                                                                           0:13
Traceback (most recent call last):
  File "toggl/__main__.py", line 4, in <module>
    from toggl.toggl import main
  File "/Users/t/Documents/toggl-cli/toggl/toggl.py", line 3, in <module>
    from toggl import cli
ImportError: cannot import name 'cli' from 'toggl' (/Users/t/Documents/toggl-cli/toggl/toggl.py)

But I was still able to create two additional functions toggle sum and toggle day by changing the source code. I have never used click before and do not understand everything. But it seems to work just fine and you can optimize it or instruct me how to improve upon it when you review the PR.

I plan to be finished testing by monday.

I would say the simplest way how to develop with toggl (and general Python packages) is to install them locally. You can do so with running pip install -e . in the root of the project. Then toggl will be added to your Python's packages using symlink so changes will be propagated. You should be then able to run the toggl command using the cloned sources. Of course it is recommended to have separate venv for the project... (check out my arctile about how to manage venvs in very easy manner)

Eh, yeah there is some problems with the tests. I really have to find some time and debug it.

Sure, sounds good. Make PR and I will review it, maybe together with it have a look on the tests and generally give some more ❤️ to this project.

commented

Hi! I realized I need more functionality. So far I was extending you toggl ls function. But I think it cannot filter for Clients?
If I am wrong about that or is there an easy fix?

Yeah you are right, it can filter only Projects. Unfortunately, it seems that for Toggl the public API is not that important anymore, because they have not released the new version for usage and the current API does not contain the Client information.

commented

Are you using the reports API? https://github.com/toggl/toggl_api_docs/blob/master/reports.md
I just tried. and I could query for a cliend_id.

Interesting. Reports API is implemented but it is used only when requested with --use-reports flag I believe. I don't remember but I think there are some limitation to that API or maybe its implementation in toggl. It is used mainly when you want to show larger reports... Maybe it the ls command could be completely implemented with Reports API and do the limitations in toggl.

commented

Yeah that sounds sensible.
I think I would just create my own client to query the toggl APIs myself, because that would actually be easier for me. I can still share you my changes so far though, if you want.
But thanks for the introduction into the field :)

Sure push whatever you feel, I will review it and will see if I incorporate it or not :-)