clickup_cli/commands/
task_type.rs1use crate::client::ClickUpClient;
2use crate::commands::auth::resolve_token;
3use crate::commands::workspace::resolve_workspace;
4use crate::error::CliError;
5use crate::output::OutputConfig;
6use crate::Cli;
7use clap::Subcommand;
8
9#[derive(Subcommand)]
10pub enum TaskTypeCommands {
11 List,
13}
14
15const TASK_TYPE_FIELDS: &[&str] = &["id", "name", "name_plural", "description"];
16
17pub async fn execute(command: TaskTypeCommands, cli: &Cli) -> Result<(), CliError> {
18 let token = resolve_token(cli)?;
19 let client = ClickUpClient::new(&token, cli.timeout)?;
20 let output = OutputConfig::from_cli(&cli.output, &cli.fields, cli.no_header, cli.quiet);
21
22 match command {
23 TaskTypeCommands::List => {
24 let ws_id = resolve_workspace(cli)?;
25 let resp = client
26 .get(&format!("/v2/team/{}/custom_item", ws_id))
27 .await?;
28 let items = resp
29 .get("custom_items")
30 .and_then(|i| i.as_array())
31 .cloned()
32 .unwrap_or_default();
33 output.print_items(&items, TASK_TYPE_FIELDS, "id");
34 Ok(())
35 }
36 }
37}