aimcal_cli/
lib.rs

1// SPDX-FileCopyrightText: 2025 Zexin Yuan <aim@yzx9.xyz>
2//
3// SPDX-License-Identifier: Apache-2.0
4
5//! Command-line interface for the AIM calendar application.
6
7#![warn(
8    missing_docs,
9    missing_copy_implementations,
10    trivial_casts,
11    trivial_numeric_casts,
12    unsafe_code,
13    unstable_features,
14    unused_import_braces,
15    unused_qualifications,
16    missing_debug_implementations,
17    clippy::indexing_slicing,
18    clippy::dbg_macro,
19    clippy::doc_markdown,
20    clippy::redundant_closure_for_method_calls
21)]
22
23mod cli;
24mod command;
25mod config;
26mod event_formatter;
27mod short_id;
28mod table;
29mod todo_formatter;
30use std::error::Error;
31
32pub use crate::{
33    cli::{Cli, Commands},
34    command::{command_dashboard, command_done, command_events, command_todos, command_undo},
35    config::Config,
36};
37
38/// Run the AIM command-line interface.
39pub async fn run() -> Result<(), Box<dyn Error>> {
40    env_logger::init();
41
42    let cli = Cli::parse();
43    match cli.command {
44        Commands::Dashboard => command_dashboard(cli.config).await?,
45        Commands::Events(args) => command_events(cli.config, &args).await?,
46        Commands::Todos(args) => command_todos(cli.config, &args).await?,
47        Commands::Done(args) => command_done(cli.config, &args).await?,
48        Commands::Undo(args) => command_undo(cli.config, &args).await?,
49    }
50    Ok(())
51}