add configurable automatic admin command execution after startup

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-08-11 23:07:58 +00:00
parent 025afb61cb
commit b2d8da489c
4 changed files with 56 additions and 2 deletions

View file

@ -24,6 +24,10 @@ pub(crate) struct Args {
/// Activate admin command console automatically after startup.
#[arg(long, num_args(0))]
pub(crate) console: bool,
/// Execute console command automatically after startup.
#[arg(long)]
pub(crate) execute: Vec<String>,
}
/// Parse commandline arguments into structured data
@ -39,6 +43,11 @@ pub(crate) fn update(mut config: Figment, args: &Args) -> Result<Figment> {
config = config.join(("admin_console_automatic", true));
}
// Execute commands after any commands listed in configuration file
for command in &args.execute {
config = config.adjoin(("admin_execute", [command]));
}
// All other individual overrides can go last in case we have options which
// set multiple conf items at once and the user still needs granular overrides.
for option in &args.option {