1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
mod cli;
mod client;
mod commands;
mod config;
mod mailurl;
mod message;
mod output;
use anyhow::Result;
use clap::Parser;
use cli::{Cli, Cmd};
fn main() -> Result<()> {
let cli = Cli::parse();
// `accounts` inspects the config file itself; everything else needs one
// resolved account.
if let Cmd::Accounts = cli.cmd {
return commands::accounts(&cli.config, cli.format);
}
let acc = config::load(&cli.config, &cli.account)?;
match cli.cmd {
Cmd::Accounts => unreachable!("handled above"),
Cmd::Folders => commands::folders(&acc, cli.format),
Cmd::Status { folder } => commands::status(&acc, &folder, cli.format),
Cmd::List {
folder,
unread,
query,
max,
} => commands::list(&acc, &folder, unread, query, max, cli.format),
Cmd::Get {
uid,
folder,
raw,
html,
mark_read,
} => commands::get(&acc, uid, &folder, raw, html, mark_read, cli.format),
Cmd::Send {
to,
cc,
subject,
body,
body_file,
no_record,
} => commands::send(&acc, &to, &cc, &subject, body, body_file, no_record),
Cmd::Mark {
state,
uids,
folder,
} => commands::mark(&acc, state, &uids, &folder),
Cmd::Move { uids, to, folder } => commands::move_cmd(&acc, &uids, &to, &folder),
Cmd::Delete { uids, folder } => {
let trash = acc.trash_folder.clone();
commands::move_cmd(&acc, &uids, &trash, &folder)
}
Cmd::Search { query, folder } => commands::search(&acc, &query, &folder, cli.format),
}
}
|