Time tracking management from python / command line
Project description
clock
Simple command-line time tracker based on a simple text file format.
Introduction
This simple utility uses a text file to store tasks with date/time information. Each time you start working on a task, a new line is created on the file with the current time and a description of the task you are starting to work on.
At the end of the day, or anytime, you can then generate reports and statistics based on the file.
File structure
The file structure is very simple and can be edited using the script or directly with your favorite text editor. Here is an example file:
[2022-01-01]
10:00 Starting project X +projectX
11:23 Starting documentation of project X +projectX +doc
12:00 [Stop]
[2022-01-02]
08:05 Starting workday, checking emails +office +emails
09:00 Back on documentation +projectX +doc
10:00 [Stop]
Tags and ids
An entry in this file can be associated with tags if you start the tag with a +
(+tag
) or ID if you start with a .
(.456
).
Tags allow for powerful filtering and reporting. They are ordered, meaning that +project +doc
is different from +doc +project
(see reports and filters below).
IDs allow to track time of tasks from an external tool, such as Jira. Entries with an ID are automatically assigned a default tag (+jira
).
Special tasks
The [Stop]
task is used to stop the last task. It is not required if you switch tasks without taking a break.
Installation
The program is available as a python packge through Pypi, so you can download it using pip:
python -m pip install clock-tracking
Creating an alias
You can create a shortcut (alias) to make the package easier to be called from the command line. Follow the instructions below depending on your operating system.
Windows PowerShell
On Windows, you can use the script with PowerShell. To create an alias permenantly, open your profile.ps1
file (see Windows PowerShell Profiles) and add these lines:
function Invoke-Clock { python -m clock_tracking $args }
New-Alias -Name clock -Value Invoke-Clock
MacOS / Unix
Open your bash profile (see Bash Profiles) and add these lines:
alias clock="python -m clock_tracking"
Usage
Tracking tasks
Use the clock_tracking
python package to run the program, i.e. python -m clock_tracking
or directly the command alias (see above). In this documentation, we'll use the alias clock
to call the python -m clock_tracking
package.
You can add a new entry by adding the entry definition after the package name:
$ clock Definition of the prototype +myapp +proto
Added: 08:10 Definition of the prototype +myapp +proto
Duration Date Start Stop Tags Name IDs
00:00 2022-01-01 08:10 08:10 +myapp,+proto Definition of the prototype
To switch to a new task, just use the same command:
$ clock Switching to new task
Added: 09:02 Switching to a new task
Duration Date Start Stop Tags Name IDs
00:00 2022-01-01 08:10 08:10 Switching to a new task
This will automatically stop the last task and start a new one. When you have finished working, use the stop
command:
$ clock stop
Added: 10:00 [Stop]
Reports
You can show reports/statistics with the show
command:
$ clock show
All tasks are ordered by first tag by default. Several filters are available, see ./clock --help
for the full documentation.
To show all the tasks with their details:
$ clock show --details
To filter by a tag:
$ clock show +tag
To filter by an ID:
$ clock show .345
Examples
Report by tags / projects:
Show today's tasks details:
Documentation
usage: __main__.py [-h] [-f FILE] [--target HH:MM] [--target-per-day HH:MM] [-a HH:MM] [-t] [-w] [-s YYYY-mm-dd] [-e YYYY-mm-dd] [-l n] [-d]
[--categories] [--timeline]
command
Helps managing time tracking from the command-line
positional arguments:
command Command (add, edit, show). add: add a new entry. edit: edit current entry's description. show: show reports and statistics.
options:
-h, --help show this help message and exit
settings:
-f FILE, --file FILE Speficy the file to store time entries. Default is ~/clock.txt
--target HH:MM <show> Sets expected target time (format HH:MM) and computes the difference with actual times in the reports
--target-per-day HH:MM
<show> Sets expected target time per day (format HH:MM) and computes the difference with actual times in the reports
add:
-a HH:MM, --at HH:MM <add> Specify a time (format HH:MM) of a new entry
filters:
-t, --today <show> Show only entries from today
-w, --week <show> Show only entries from the current week
-s YYYY-mm-dd, --from YYYY-mm-dd
<show> Include entries with start date later or equal to given date (format YYYY-mm-dd)
-e YYYY-mm-dd, --to YYYY-mm-dd
<show> Include entries with start date earlier or equal to given date (format YYYY-mm-dd)
-l n, --last n <show> Show only the last n entries
reports:
-d, --details <show> Shows detailed report
--categories <show> Shows categories report (default)
--timeline <show> Shows issues on a timeline (only when --today is specified)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file clock-tracking-0.0.7.tar.gz
.
File metadata
- Download URL: clock-tracking-0.0.7.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90dfa06d72a4063a1131ed6b1aab4540926b01cf49f024ddab666b40911ec3d9 |
|
MD5 | c98ec729f7bec51ce4a15df5d283cf14 |
|
BLAKE2b-256 | aa3fc8a1ce66a99a017138ad214057991436b84a2c106085af694e1d544edcbe |
File details
Details for the file clock_tracking-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: clock_tracking-0.0.7-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1a0a17cb3d17d40cb9e14161f99bbd5e8c50e09950a8f35f9ff19299feec8be |
|
MD5 | 7214b0195f507a9033e7c600a1ddb051 |
|
BLAKE2b-256 | 7945ad2ecb7810c0486b38fe05a297dd4cc69b08e30abe4a319f60732fe756cf |