1pub mod app;
2pub mod cli;
3pub mod commands;
4pub mod config;
5pub mod db;
6pub mod jira;
7pub mod report;
8pub mod sync;
9pub mod time;
10pub mod toggl;
11
12pub async fn run(cli: cli::Cli) -> anyhow::Result<()> {
13 match cli.command {
14 Some(cli::Command::Sync(args)) => commands::sync::run(args).await,
15 Some(cli::Command::Recover(args)) => commands::recover::run(args).await,
16 Some(cli::Command::Config(args)) => commands::config::run(args).await,
17 Some(cli::Command::Doctor(args)) => commands::doctor::run(args).await,
18 Some(cli::Command::Status(args)) => commands::status::run(args).await,
19 Some(cli::Command::Tui(args)) => commands::tui::run(args).await,
20 Some(cli::Command::Schedule(args)) => commands::schedule::run(args),
21 None => {
22 commands::tui::run(cli::TuiArgs {
23 paths: cli::SharedPaths {
24 config: None,
25 db: None,
26 },
27 limit: 200,
28 })
29 .await
30 }
31 }
32}
33
34pub fn format_error_chain(error: &anyhow::Error) -> String {
35 let mut lines = Vec::new();
36
37 for cause in error.chain() {
38 let line = cause.to_string();
39 if lines.last() != Some(&line) {
40 lines.push(line);
41 }
42 }
43
44 lines.join("\n")
45}