summaryrefslogtreecommitdiff
path: root/utils/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--utils/src/main.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/utils/src/main.rs b/utils/src/main.rs
index d49a3d7..bcd63f6 100644
--- a/utils/src/main.rs
+++ b/utils/src/main.rs
@@ -42,6 +42,9 @@ struct Options {
/// encrypt the survey with the given password (not yet implemented)
#[structopt(long, short)]
password: Option<secrecy::Secret<String>>,
+ /// file to write the configuration to (will otherwise print to stdout)
+ #[structopt(long, short)]
+ out_file: Option<PathBuf>
}
fn main () {
@@ -97,7 +100,15 @@ fn main () {
encrypted.as_slice()
}
};
- fs::write("outfile", outdata).expect("cannot write to outfile!");
+ match opt.out_file {
+ Some(file) => fs::write(file.clone(), outdata)
+ .expect(&format!("cannot write to file {:?}!", file)),
+ None => {
+ let mut out = std::io::stdout();
+ out.write_all(outdata).unwrap();
+ out.flush().unwrap()
+ }
+ };
}
}
}