Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ cu task create
# View task details
cu task view <task-id>

# Archive a task (reversible; keeps history and URL)
cu task archive <task-id>
cu task archive <task-id> --undo

# Export tasks to CSV
cu export tasks --format csv > tasks.csv
```
Expand Down
1 change: 1 addition & 0 deletions docs/site/commands/cu_task.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Create, view, update, and manage ClickUp tasks.
### SEE ALSO

* [cu](cu.md) - A GitHub CLI-inspired command-line interface for ClickUp
* [cu task archive](cu_task_archive.md) - Archive a task
* [cu task close](cu_task_close.md) - Close a task
* [cu task create](cu_task_create.md) - Create a new task
* [cu task interactive](cu_task_interactive.md) - Interactive task browser
Expand Down
37 changes: 37 additions & 0 deletions docs/site/commands/cu_task_archive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## cu task archive

Archive a task

### Synopsis

Archive a task, removing it from active views while keeping its history
and URL intact.

Archiving is reversible with --undo. Prefer it over closing a task whose work
has moved elsewhere: closing asserts a status the task never reached, and not
every list even has a status named "closed".

```
cu task archive [task-id] [flags]
```

### Options

```
-h, --help help for archive
--undo Unarchive instead of archiving
```

### Options inherited from parent commands

```
--config string config file (default is $HOME/.config/cu/config.yaml)
--debug enable debug mode
-o, --output string output format (table|json|yaml|csv) (default "table")
```

### SEE ALSO

* [cu task](cu_task.md) - Manage tasks

###### Auto generated by spf13/cobra on 28-Aug-2026
41 changes: 41 additions & 0 deletions internal/api/archive.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package api

import (
"context"
"fmt"

"github.com/raksul/go-clickup/clickup"
)

// archiveRequest is sent directly rather than through clickup.TaskUpdateRequest,
// which has no archived field — the SDK cannot express this update.
type archiveRequest struct {
Archived bool `json:"archived"`
}

// SetTaskArchived archives or unarchives a task.
//
// Archiving keeps the task, its history and its URL while removing it from
// active views. That makes it the right primitive for retiring a task whose
// work has moved elsewhere: closing it would assert a status the task never
// reached (and "closed" is not even a status name on every list), and deleting
// it destroys the record.
func (c *Client) SetTaskArchived(ctx context.Context, taskID string, archived bool) (*clickup.Task, error) {
if taskID == "" {
return nil, fmt.Errorf("a task id is required")
}
if err := c.rateLimiter.Wait(ctx); err != nil {
return nil, err
}

req, err := c.client.NewRequest("PUT", fmt.Sprintf("task/%s", taskID), &archiveRequest{Archived: archived})
if err != nil {
return nil, err
}

task := new(clickup.Task)
if _, err := c.client.Do(ctx, req, task); err != nil {
return nil, c.handleError(err)
}
return task, nil
}
43 changes: 43 additions & 0 deletions internal/cmd/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,47 @@ var taskReopenCmd = &cobra.Command{
},
}

var taskArchiveCmd = &cobra.Command{
Use: "archive [task-id]",
Short: "Archive a task",
Long: `Archive a task, removing it from active views while keeping its history
and URL intact.

Archiving is reversible with --undo. Prefer it over closing a task whose work
has moved elsewhere: closing asserts a status the task never reached, and not
every list even has a status named "closed".`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
taskID := args[0]
undo, _ := cmd.Flags().GetBool("undo")

client, err := api.NewClient()
if err != nil {
return err
}

task, err := client.SetTaskArchived(context.Background(), taskID, !undo)
if err != nil {
return err
}

verb := "Archived"
if undo {
verb = "Unarchived"
}

if outputFormat != "table" {
return output.Format(outputFormat, task)
}

fmt.Printf("✓ %s task %s: %s\n", verb, task.ID, task.Name)
if task.URL != "" {
fmt.Printf(" View in ClickUp: %s\n", task.URL)
}
return nil
},
}

var taskSearchCmd = &cobra.Command{
Use: "search [query]",
Short: "Search for tasks",
Expand Down Expand Up @@ -683,6 +724,7 @@ func init() {
taskCmd.AddCommand(taskCloseCmd)
taskCmd.AddCommand(taskReopenCmd)
taskCmd.AddCommand(taskSearchCmd)
taskCmd.AddCommand(taskArchiveCmd)

// List command flags
taskListCmd.Flags().StringP("list", "l", "", "List ID or name")
Expand Down Expand Up @@ -719,6 +761,7 @@ func init() {
taskUpdateCmd.Flags().StringSlice("remove-assignee", []string{}, "Remove assignees (username or ID)")

// Reopen command flags
taskArchiveCmd.Flags().Bool("undo", false, "Unarchive instead of archiving")
taskCloseCmd.Flags().StringP("status", "s", "", "Status to set (default: the list's done status)")
taskReopenCmd.Flags().StringP("status", "s", "", "Status to set (default: the list's first open status)")

Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ nav:
- cu task close: commands/cu_task_close.md
- cu task reopen: commands/cu_task_reopen.md
- cu task search: commands/cu_task_search.md
- cu task archive: commands/cu_task_archive.md
- cu task interactive: commands/cu_task_interactive.md
- Lists:
- cu list: commands/cu_list.md
Expand Down
Loading