toggl 0.5.0

Unofficial command-line interface for Toggl Track using the v9 API.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::api::client::ApiClient;
use crate::models::ResultWithDefaultError;
use colored::Colorize;

pub struct CreateTagCommand;

impl CreateTagCommand {
    pub async fn execute(api_client: impl ApiClient, name: String) -> ResultWithDefaultError<()> {
        let workspace_id = api_client.get_user().await?.default_workspace_id;
        match api_client.create_tag(workspace_id, name).await {
            Err(error) => println!("{}\n{}", "Couldn't create tag".red(), error),
            Ok(tag) => println!("{}\n{}", "Tag created successfully".green(), tag),
        }
        Ok(())
    }
}