11import { Command } from 'commander'
22import { createRequire } from 'module'
3+ import { ClickUpClient } from './api.js'
34import { loadConfig } from './config.js'
45import { fetchMyTasks , printTasks } from './commands/tasks.js'
5- import { updateTask , buildUpdatePayload } from './commands/update.js'
6+ import { updateTask , buildUpdatePayload , resolveAssigneeId } from './commands/update.js'
67import type { UpdateCommandOptions } from './commands/update.js'
78import { createTask } from './commands/create.js'
89import 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