MCPcopy Create free account
hub / github.com/Noumena-Network/code / taskUpdateHandler

Function taskUpdateHandler

src/cli/handlers/ant.ts:815–865  ·  view source on GitHub ↗
(
  id: string,
  opts: TaskUpdateOptions = {},
)

Source from the content-addressed store, hash-verified

813}
814
815export async function taskUpdateHandler(
816 id: string,
817 opts: TaskUpdateOptions = {},
818): Promise<void> {
819 try {
820 if (opts.clearOwner && opts.owner) {
821 throw new Error('Use either --owner or --clear-owner, not both.')
822 }
823 if (opts.status && !TASK_STATUSES.includes(opts.status as Task['status'])) {
824 throw new Error(
825 `Invalid status "${opts.status}". Expected one of: ${TASK_STATUSES.join(', ')}.`,
826 )
827 }
828
829 const updates: Partial<Omit<Task, 'id'>> = {}
830 if (typeof opts.status !== 'undefined') {
831 updates.status = opts.status as Task['status']
832 }
833 if (typeof opts.subject !== 'undefined') {
834 updates.subject = opts.subject
835 }
836 if (typeof opts.description !== 'undefined') {
837 updates.description = opts.description
838 }
839 if (typeof opts.owner !== 'undefined') {
840 updates.owner = opts.owner
841 }
842 if (opts.clearOwner) {
843 updates.owner = undefined
844 }
845
846 if (Object.keys(updates).length === 0) {
847 throw new Error('No updates were specified.')
848 }
849
850 const taskListId = normalizeTaskListId(opts.list)
851 const task = await updateTask(taskListId, id, updates)
852 if (!task) {
853 throw new Error(`Task ${id} was not found in ${taskListId}.`)
854 }
855
856 writeJson({
857 taskListId,
858 task,
859 })
860 await gracefulShutdown(0)
861 } catch (error) {
862 writeToStderr(`Failed to update task: ${errorMessage(error)}\n`)
863 await gracefulShutdown(1)
864 }
865}
866
867export async function taskDirHandler(
868 opts: TaskListOptions = {},

Callers 1

runFunction · 0.85

Calls 7

normalizeTaskListIdFunction · 0.85
updateTaskFunction · 0.85
writeJsonFunction · 0.85
gracefulShutdownFunction · 0.85
writeToStderrFunction · 0.85
keysMethod · 0.80
errorMessageFunction · 0.50

Tested by

no test coverage detected