mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-15 11:27:53 +08:00
07078437a2
Clap env vars are hard to customize across Pimalaya projects, and they can always be replaced by arg or flag.
55 lines
1.6 KiB
Rust
55 lines
1.6 KiB
Rust
// This file is part of Himalaya, a CLI to manage emails.
|
|
//
|
|
// Copyright (C) 2022-2026 soywod <pimalaya.org@posteo.net>
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify it under
|
|
// the terms of the GNU Affero General Public License as published by the Free
|
|
// Software Foundation, either version 3 of the License, or (at your option) any
|
|
// later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
// details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
mod account;
|
|
mod backend;
|
|
mod cli;
|
|
mod config;
|
|
#[cfg(feature = "imap")]
|
|
mod imap;
|
|
#[cfg(feature = "jmap")]
|
|
mod jmap;
|
|
#[cfg(feature = "m2dir")]
|
|
mod m2dir;
|
|
#[cfg(feature = "maildir")]
|
|
mod maildir;
|
|
mod shared;
|
|
#[cfg(feature = "smtp")]
|
|
mod smtp;
|
|
mod wizard;
|
|
|
|
use anyhow::Result;
|
|
use clap::Parser;
|
|
use pimalaya_cli::{error::ErrorReport, log::Logger, printer::StdoutPrinter};
|
|
|
|
use crate::cli::Cli;
|
|
|
|
fn main() {
|
|
let cli = Cli::parse();
|
|
let mut printer = StdoutPrinter::new(&cli.json);
|
|
let result = execute(cli, &mut printer);
|
|
ErrorReport::eval(&mut printer, result);
|
|
}
|
|
|
|
fn execute(cli: Cli, printer: &mut StdoutPrinter) -> Result<()> {
|
|
Logger::try_init(&cli.log)?;
|
|
let config = cli.config.paths.as_ref();
|
|
let account = cli.account.name.as_deref();
|
|
let backend = cli.backend;
|
|
cli.cmd.execute(printer, config, account, backend)
|
|
}
|