1use dialoguer::Confirm;
2use std::env;
3use tgl_cli::api;
4
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let token = env::var("TOGGL_API_TOKEN").expect("missing TOGGL_API_TOKEN environment variable");
7 let client = api::Client::new(token)?;
8 let workspaces = client.get_workspaces()?;
9
10 if Confirm::new().with_prompt("Print workspaces?").interact()? {
11 println!("{workspaces:#?}");
12 }
13
14 for w in workspaces {
15 let projects = client.get_projects(&w.id)?;
16 let projects: Vec<_> = projects.iter().filter(|p| p.active).collect();
17
18 if Confirm::new()
19 .with_prompt("Print active projects?")
20 .interact()?
21 {
22 println!("{projects:#?}");
23 }
24
25 let time_entries = client.get_time_entries(None)?;
26
27 if Confirm::new()
28 .with_prompt("Print recent time entries?")
29 .interact()?
30 {
31 println!("{time_entries:#?}");
32 }
33 }
34
35 Ok(())
36}