介绍
# Toggl Time Tracking
使用 `toggl` CLI (@beauraines/toggl-cli) 进行 Toggl Track 集成。
## 前置条件
安装 CLI: ```bash npm install -g @beauraines/toggl-cli ```
配置身份验证(创建 `~/.toggl-cli.json`): ```json { "api_token": "YOUR_TOGGL_API_TOKEN", "default_workspace_id": "YOUR_WORKSPACE_ID", "timezone": "Your/Timezone" } ```
从以下位置获取您的 API 令牌:https://track.toggl.com/profile 从您的 Toggl URL 中获取工作区 ID:`https://track.toggl.com/{workspace_id}/...`
设置权限:`chmod 600 ~/.toggl-cli.json`
## 命令
### 状态 ```bash toggl now # Show running timer toggl me # Show user info ```
### 开始/停止 ```bash toggl start # Start timer (interactive) toggl start -d "Task name" # Start with description toggl start -d "Task" -p "Project" # With project toggl stop # Stop current timer ```
### 继续上一次 ```bash toggl continue # Restart most recent entry toggl continue "keyword" # Restart entry matching keyword ```
### 报告 ```bash toggl today # Today's time by project toggl week # Weekly summary by day ```
### 列出条目 ```bash toggl ls # Last 14 days toggl ls -d 7 # Last 7 days toggl ls --today # Today only toggl ls "search term" # Search entries ```
### 添加已完成条目 ```bash toggl add "9:00AM" "10:30AM" "Meeting notes" ```
### 编辑当前条目 ```bash toggl edit -s "10:00AM" # Change start time toggl edit -d "New desc" # Change description toggl edit -p "Project" # Change project ```
### 删除 ```bash toggl rm <id> # Remove entry by ID ```
### 项目 ```bash toggl project ls # List projects ```
### 其他 ```bash toggl web # Open Toggl in browser toggl create-config # Generate config template ```
## 注意事项
- 时间必须能被 dayjs 解析(例如 `4:50PM`, `12:00 AM`, `9:00`) - 配置文件:`~/.toggl-cli.json` - 环境变量会覆盖配置:`TOGGL_API_TOKEN`, `TOGGL_DEFAULT_WORKSPACE_ID`, `TOGGL_TIMEZONE`