split out proxmox-backup-debug binary

and introduce pbs_tools::cli module

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2021-08-31 14:45:48 +02:00
parent dd2162f6bd
commit e5f9b7f79e
11 changed files with 49 additions and 33 deletions

13
pbs-tools/src/cli.rs Normal file
View File

@ -0,0 +1,13 @@
use std::fs::File;
use std::io::{self, stdout, Write};
use std::path::Path;
/// Returns either a new file, if a path is given, or stdout, if no path is given.
pub fn outfile_or_stdout<P: AsRef<Path>>(path: Option<P>) -> io::Result<Box<dyn Write>> {
if let Some(path) = path {
let f = File::create(path)?;
Ok(Box::new(f) as Box<dyn Write>)
} else {
Ok(Box::new(stdout()) as Box<dyn Write>)
}
}

View File

@ -4,6 +4,7 @@ pub mod blocking;
pub mod borrow;
pub mod broadcast_future;
pub mod cert;
pub mod cli;
pub mod compression;
pub mod format;
pub mod fs;