41 个稳定版本
1.5.20 | 2021年4月28日 |
---|---|
1.5.19 | 2021年4月22日 |
#211 in 日期和时间
80 每月下载次数
45KB
1K SLoC
时间追踪
这是一个简单的命令行时间追踪应用程序,我写它来记录我一周内已经工作了多少小时。
安装
cargo install timetracking
命令行
USAGE:
tt [OPTIONS] [SUBCOMMAND]
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-c, --config-file <config-file> which config file to use
-d, --data-file <data-file> which data file to use. [default: ~/timetracking.bin]
SUBCOMMANDS:
cleanup starts an interactive cleanup session
continue continue time tracking with last description
export export data to file
help Prints this message or the help of the given subcommand(s)
import import data from json file
list list all entries
path show path to data file
show show work time for given timespan
start start time tracking
status show info from the latest entry. Returns the exit code 0, if the time tracking is currently active
and -1 if not
stop stop time tracking
使用示例
开始追踪:tt start
停止追踪:tt stop
显示当天的工作时间:tt show
显示本周的工作时间:tt show week
列出当天所有条目:tt list
导出到 json:tt export backup.json
从 json 导入:tt import backup.json
配置
tt
支持全局配置(~/.config/timetracking/config.toml
)、项目配置(timetracking.project.toml
)和本地配置(.timetracking.toml
)。
以下设置是被支持的
# the file where to save the events
data_file = "~/timetracking.bin"
# if true, calling start when already running inserts a stop event and a start event.
auto_insert_stop = false
# if true, tt will recursively search parent dirs for project settings
enable_project_settings = true
# minimum amount of minutes of break time per day.
# if you have less than this amount of break per day,
# the calculation will automatically add the additional
# break time needed to get to this number
min_daily_break = 0
# last day of work week as chrono::Weekday.
# allowed values are: mon, tue, wed, thu, fri, sat and sun
last_day_of_work_week = "fri"
# set the daily time goal
[time_goal.daily]
# work hours to reach in a work day (0-24)
hours = 8
# work minutes to reach in a work day (0-59)
minutes = 0
# set the weekly time goal
[time_goal.weekly]
# work hours to reach in a work week (0-168)
hours = 40
# work minutes to reach in a work week (0-59)
minutes = 0
读取配置文件的顺序是
- 全局
- 项目
- 本地
配置覆盖早期加载的配置。
项目配置是特殊的,将从当前目录开始递归搜索。所以如果你在 /a/b/c,搜索顺序将是
- /a/b/c/timetracking.project.toml
- /a/b/timetracking.project.toml
- /a/timetracking.project.toml
- /timetracking.project.toml
可以在全局配置文件中禁用项目配置。
Starship
你可以使用以下代码片段来显示你在时间追踪运行期间今天的工作时间。
只需将其添加到你的 Starship 配置文件中(例如:~/.config/starship.toml)
[custom.worktime]
command = """ tt show --format "{h}h {mm}m" """
when = "tt status"
shell = "sh"
它看起来是这样的
数据格式
数据格式是一个以bincode编码的TrackingEvent
向量,可以是开始或停止事件,包含事件发生的DateTime
以及可选的描述。如果您想在第三方应用程序中使用这些数据,可以使用tt export data.json
将数据导出为json格式。
依赖关系
~4–6MB
~98K SLoC