Skip to content

Commit 27b8bee

Browse files
committed
support --assignee me on cu create and cu update
1 parent 0ade4cc commit 27b8bee

File tree

5 files changed

+42
-32
lines changed

5 files changed

+42
-32
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ cu update abc123 -n "New task name"
201201
cu update abc123 -d "Updated description with **markdown**"
202202
cu update abc123 --priority high
203203
cu update abc123 --due-date 2025-03-15
204+
cu update abc123 --assignee me
204205
cu update abc123 --assignee 12345
205206
cu update abc123 -n "New name" -s "done" --priority urgent
206207
cu update abc123 --time-estimate 2h
@@ -216,7 +217,7 @@ cu update abc123 -s "in progress" --json
216217
| `--priority <level>` | Priority: `urgent`, `high`, `normal`, `low` (or 1-4) |
217218
| `--due-date <date>` | Due date (`YYYY-MM-DD`) |
218219
| `--time-estimate <duration>` | Time estimate (e.g. `"2h"`, `"30m"`, `"1h30m"`) |
219-
| `--assignee <userId>` | Add assignee by numeric user ID |
220+
| `--assignee <userId>` | Add assignee by user ID or `"me"` |
220221
| `--parent <taskId>` | Set parent task (makes this a subtask) |
221222
| `--json` | Force JSON output even in terminal |
222223

@@ -229,7 +230,7 @@ cu create -n "Fix login bug" -l <listId>
229230
cu create -n "Subtask name" -p <parentTaskId> # --list auto-detected
230231
cu create -n "Task" -l <listId> -d "desc" -s "open"
231232
cu create -n "Task" -l <listId> --priority high --due-date 2025-06-01
232-
cu create -n "Task" -l <listId> --assignee 12345 --tags "bug,frontend"
233+
cu create -n "Task" -l <listId> --assignee me --tags "bug,frontend"
233234
cu create -n "Initiative" -l <listId> --custom-item-id 1
234235
cu create -n "Task" -l <listId> --time-estimate 2h
235236
cu create -n "Fix bug" -l <listId> --json
@@ -245,7 +246,7 @@ cu create -n "Fix bug" -l <listId> --json
245246
| `--priority <level>` | no | Priority: `urgent`, `high`, `normal`, `low` (or 1-4) |
246247
| `--due-date <date>` | no | Due date (`YYYY-MM-DD`) |
247248
| `--time-estimate <duration>` | no | Time estimate (e.g. `"2h"`, `"30m"`, `"1h30m"`) |
248-
| `--assignee <userId>` | no | Assignee by numeric user ID |
249+
| `--assignee <userId>` | no | Assignee by user ID or `"me"` |
249250
| `--tags <tags>` | no | Comma-separated tag names |
250251
| `--custom-item-id <id>` | no | Custom task type ID (e.g. for creating initiatives) |
251252
| `--json` | no | Force JSON output even in terminal |

skills/clickup-cli/SKILL.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ All commands support `--help` for full flag details.
5555

5656
### Write
5757

58-
| Command | What it does |
59-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------- |
60-
| `cu update <id> [-n name] [-d desc] [-s status] [--priority p] [--due-date d] [--time-estimate t] [--assignee id] [--parent id] [--json]` | Update task fields (desc supports markdown) |
61-
| `cu create -n name [-l listId] [-p parentId] [-d desc] [-s status] [--priority p] [--due-date d] [--time-estimate t] [--assignee id] [--tags t] [--custom-item-id n] [--json]` | Create task (desc supports markdown) |
62-
| `cu comment <id> -m text [--json]` | Post comment on task |
63-
| `cu assign <id> [--to userId\|me] [--remove userId\|me] [--json]` | Assign/unassign users |
64-
| `cu depend <id> [--on taskId] [--blocks taskId] [--remove] [--json]` | Add/remove task dependencies |
65-
| `cu move <id> [--to listId] [--remove listId] [--json]` | Add/remove task from lists |
66-
| `cu field <id> [--set "Name" value] [--remove "Name"] [--json]` | Set/remove custom field values |
67-
| `cu delete <id> [--confirm] [--json]` | Delete a task (DESTRUCTIVE, irreversible) |
68-
| `cu tag <id> [--add tags] [--remove tags] [--json]` | Add/remove tags on a task |
69-
| `cu config get <key>` / `cu config set <key> <value>` / `cu config path` | Manage CLI config |
70-
| `cu completion <shell>` | Shell completions (bash/zsh/fish) |
58+
| Command | What it does |
59+
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
60+
| `cu update <id> [-n name] [-d desc] [-s status] [--priority p] [--due-date d] [--time-estimate t] [--assignee id\|me] [--parent id] [--json]` | Update task fields (desc supports markdown) |
61+
| `cu create -n name [-l listId] [-p parentId] [-d desc] [-s status] [--priority p] [--due-date d] [--time-estimate t] [--assignee id\|me] [--tags t] [--custom-item-id n] [--json]` | Create task (desc supports markdown) |
62+
| `cu comment <id> -m text [--json]` | Post comment on task |
63+
| `cu assign <id> [--to userId\|me] [--remove userId\|me] [--json]` | Assign/unassign users |
64+
| `cu depend <id> [--on taskId] [--blocks taskId] [--remove] [--json]` | Add/remove task dependencies |
65+
| `cu move <id> [--to listId] [--remove listId] [--json]` | Add/remove task from lists |
66+
| `cu field <id> [--set "Name" value] [--remove "Name"] [--json]` | Set/remove custom field values |
67+
| `cu delete <id> [--confirm] [--json]` | Delete a task (DESTRUCTIVE, irreversible) |
68+
| `cu tag <id> [--add tags] [--remove tags] [--json]` | Add/remove tags on a task |
69+
| `cu config get <key>` / `cu config set <key> <value>` / `cu config path` | Manage CLI config |
70+
| `cu completion <shell>` | Shell completions (bash/zsh/fish) |
7171

7272
## Quick Reference
7373

@@ -79,7 +79,7 @@ All commands support `--help` for full flag details.
7979
| `--status` | Fuzzy matching: exact > starts-with > contains. Prints match to stderr. |
8080
| `--priority` | Names (`urgent`, `high`, `normal`, `low`) or numbers (1-4) |
8181
| `--due-date` | `YYYY-MM-DD` format |
82-
| `--assignee` | Numeric user ID (find via `cu task <id> --json`) |
82+
| `--assignee` | User ID or `me` (on `cu create`, `cu update`, `cu assign`) |
8383
| `--tags` | Comma-separated (e.g. `--tags "bug,frontend"`) |
8484
| `--time-estimate` | Duration format: `"2h"`, `"30m"`, `"1h30m"`, or raw milliseconds |
8585
| `--custom-item-id` | Custom task type ID for `cu create` (e.g. `1` for initiative) |

src/commands/assign.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
import { ClickUpClient } from '../api.js'
22
import type { Task } from '../api.js'
33
import type { Config } from '../config.js'
4-
import { parseAssigneeId } from './update.js'
4+
import { resolveAssigneeId } from './update.js'
55

66
interface AssignOptions {
77
to?: string
88
remove?: string
99
json?: boolean
1010
}
1111

12-
async function resolveUserId(client: ClickUpClient, value: string): Promise<number> {
13-
if (value === 'me') {
14-
const user = await client.getMe()
15-
return user.id
16-
}
17-
return parseAssigneeId(value)
18-
}
19-
2012
export async function assignTask(
2113
config: Config,
2214
taskId: string,
@@ -32,10 +24,10 @@ export async function assignTask(
3224
const rem: number[] = []
3325

3426
if (opts.to) {
35-
add.push(await resolveUserId(client, opts.to))
27+
add.push(await resolveAssigneeId(client, opts.to))
3628
}
3729
if (opts.remove) {
38-
rem.push(await resolveUserId(client, opts.remove))
30+
rem.push(await resolveAssigneeId(client, opts.remove))
3931
}
4032

4133
return client.updateTask(taskId, {

src/commands/update.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,18 @@ export function parseDueDate(value: string): number {
2929

3030
export function parseAssigneeId(value: string): number {
3131
const id = Number(value)
32-
if (!Number.isInteger(id)) throw new Error('Assignee must be a numeric user ID')
32+
if (!Number.isInteger(id)) throw new Error('Assignee must be a numeric user ID or "me"')
3333
return id
3434
}
3535

36+
export async function resolveAssigneeId(client: ClickUpClient, value: string): Promise<number> {
37+
if (value === 'me') {
38+
const user = await client.getMe()
39+
return user.id
40+
}
41+
return parseAssigneeId(value)
42+
}
43+
3644
export function parseTimeEstimate(value: string): number {
3745
const pattern = /^(?:(\d+)h)?(?:(\d+)m)?$/i
3846
const match = value.match(pattern)

src/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Command } from 'commander'
22
import { createRequire } from 'module'
3+
import { ClickUpClient } from './api.js'
34
import { loadConfig } from './config.js'
45
import { fetchMyTasks, printTasks } from './commands/tasks.js'
5-
import { updateTask, buildUpdatePayload } from './commands/update.js'
6+
import { updateTask, buildUpdatePayload, resolveAssigneeId } from './commands/update.js'
67
import type { UpdateCommandOptions } from './commands/update.js'
78
import { createTask } from './commands/create.js'
89
import type { CreateOptions } from './commands/create.js'
@@ -159,12 +160,16 @@ program
159160
.option('--priority <level>', 'Priority: urgent, high, normal, low (or 1-4)')
160161
.option('--due-date <date>', 'Due date (YYYY-MM-DD)')
161162
.option('--time-estimate <duration>', 'Time estimate (e.g. "2h", "30m", "1h30m")')
162-
.option('--assignee <userId>', 'Add assignee by user ID')
163+
.option('--assignee <userId>', 'Add assignee by user ID or "me"')
163164
.option('--parent <taskId>', 'Set parent task (makes this a subtask)')
164165
.option('--json', 'Force JSON output even in terminal')
165166
.action(
166167
wrapAction(async (taskId: string, opts: UpdateCommandOptions & { json?: boolean }) => {
167168
const config = loadConfig()
169+
if (opts.assignee === 'me') {
170+
const client = new ClickUpClient(config)
171+
opts.assignee = String(await resolveAssigneeId(client, 'me'))
172+
}
168173
const payload = buildUpdatePayload(opts)
169174
const result = await updateTask(config, taskId, payload)
170175
if (shouldOutputJson(opts.json ?? false)) {
@@ -185,14 +190,18 @@ program
185190
.option('-s, --status <status>', 'Initial status')
186191
.option('--priority <level>', 'Priority: urgent, high, normal, low (or 1-4)')
187192
.option('--due-date <date>', 'Due date (YYYY-MM-DD)')
188-
.option('--assignee <userId>', 'Assignee user ID')
193+
.option('--assignee <userId>', 'Assignee user ID or "me"')
189194
.option('--tags <tags>', 'Comma-separated tag names')
190195
.option('--custom-item-id <id>', 'Custom task type ID (use to create initiatives)')
191196
.option('--time-estimate <duration>', 'Time estimate (e.g. "2h", "30m", "1h30m")')
192197
.option('--json', 'Force JSON output even in terminal')
193198
.action(
194199
wrapAction(async (opts: CreateOptions & { json?: boolean }) => {
195200
const config = loadConfig()
201+
if (opts.assignee === 'me') {
202+
const client = new ClickUpClient(config)
203+
opts.assignee = String(await resolveAssigneeId(client, 'me'))
204+
}
196205
const result = await createTask(config, opts)
197206
if (shouldOutputJson(opts.json ?? false)) {
198207
console.log(JSON.stringify(result, null, 2))

0 commit comments

Comments
 (0)