1pub mod cli;
2
3mod file;
4mod io;
5mod password;
6mod enc;
7mod dec;
8
9#[cfg(test)]
10mod tests;
11
12const DEFINITE_BAR_STYLE: &str = "[{elapsed_precise}] {binary_bytes_per_sec} {bar} {binary_bytes}/{binary_total_bytes} ({eta})";
13const INDEFINITE_BAR_STYLE: &str = "[{elapsed_precise}] {binary_bytes_per_sec} ({eta})";
14
15#[inline]
16fn handle_err(result: Result<(), ()>) -> std::process::ExitCode {
17 match result {
18 Ok(()) => std::process::ExitCode::SUCCESS,
19 Err(()) => std::process::ExitCode::FAILURE
20 }
21}
22
23async fn run_with_io<B: io::IoBundle>(cli: cli::Cli, io: B) -> std::process::ExitCode {
24 match cli.command {
25 cli::Command::Enc(args) => handle_err(enc::enc(args, io).await),
26 cli::Command::Dec(args) => handle_err(dec::dec_file(args, io).await),
27 cli::Command::Fetch(args) => handle_err(dec::dec_fetch(args, io).await)
28 }
29}
30
31pub async fn run(cli: cli::Cli) -> std::process::ExitCode {
32 run_with_io(cli, io::InteractiveIo).await
33}