feat: add args

This commit is contained in:
2020-11-07 21:41:04 +08:00
parent 76beb992a3
commit 297dca28f3

View File

@@ -1,4 +1,4 @@
use std::io::Read;
use std::io::{ Read, Write };
use std::fs::File;
use ring::digest;
use virt_enclave::sig::*;
@@ -31,4 +31,15 @@ fn main() {
println!("File : {}", f);
println!("Hex : {}", digest_hex);
println!("Signed: {}", serde_json::to_string(&signed_message).unwrap());
if let Some(of) = args.next() {
if File::open(&of).is_ok() {
println!("Output file exists: {}", of);
return;
}
if let Ok(mut out_file) = File::create(&of) {
out_file.write_all(&serde_json::to_string(&signed_message).unwrap().as_bytes()).ok();
println!("Write file successed: {}", of);
}
}
}