Set up plugin structure

This commit is contained in:
Jack Grigg
2020-12-31 21:17:35 +00:00
parent 05f7f1b076
commit 0052d91aad
5 changed files with 616 additions and 2 deletions
+35 -2
View File
@@ -1,3 +1,36 @@
fn main() {
println!("Hello, world!");
use age_plugin::run_state_machine;
use gumdrop::Options;
mod error;
mod plugin;
use error::Error;
#[derive(Debug, Options)]
struct PluginOptions {
#[options(help = "Print this help message and exit.")]
help: bool,
#[options(
help = "Run the given age plugin state machine. Internal use only.",
meta = "STATE-MACHINE",
no_short
)]
age_plugin: Option<String>,
}
fn main() -> Result<(), Error> {
let opts = PluginOptions::parse_args_default_or_exit();
if let Some(state_machine) = opts.age_plugin {
run_state_machine(
&state_machine,
|| plugin::RecipientPlugin::default(),
|| plugin::IdentityPlugin::default(),
)?;
Ok(())
} else {
// TODO: CLI identity generation
Ok(())
}
}