ssec_cli/
lib.rs

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