Main: Add command line option to make the process idle indefinitely
This commit is contained in:
parent
7096902052
commit
e3f83ebe8e
1 changed files with 13 additions and 0 deletions
13
src/main.rs
13
src/main.rs
|
@ -1,6 +1,7 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::thread;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
|
@ -18,12 +19,18 @@ struct Arguments {
|
||||||
|
|
||||||
/// The path to write the built secret file to
|
/// The path to write the built secret file to
|
||||||
output_path: PathBuf,
|
output_path: PathBuf,
|
||||||
|
|
||||||
|
/// If the process should keep running without doing anything. This is used to keep a systemd service
|
||||||
|
/// running this and the associated RuntimeDirectory alive.
|
||||||
|
#[clap(long, default_value_t = false)]
|
||||||
|
idle: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let Arguments {
|
let Arguments {
|
||||||
contents_path,
|
contents_path,
|
||||||
output_path,
|
output_path,
|
||||||
|
idle
|
||||||
} = Arguments::parse();
|
} = Arguments::parse();
|
||||||
|
|
||||||
let mut handlebars = Handlebars::new();
|
let mut handlebars = Handlebars::new();
|
||||||
|
@ -91,5 +98,11 @@ fn main() -> Result<()> {
|
||||||
fs::write(&output_path, output)
|
fs::write(&output_path, output)
|
||||||
.expect(format!("To be able to write to '{}'", output_path.to_string_lossy()).as_str());
|
.expect(format!("To be able to write to '{}'", output_path.to_string_lossy()).as_str());
|
||||||
|
|
||||||
|
if idle {
|
||||||
|
loop {
|
||||||
|
thread::park();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue