diff --git a/.gitignore b/.gitignore index 96ef6c0b9..3e0525451 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target Cargo.lock +keyring-util/target diff --git a/keyring-util/Cargo.toml b/keyring-util/Cargo.toml new file mode 100644 index 000000000..741b2d3c1 --- /dev/null +++ b/keyring-util/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "keyring-util" +version = "0.1.0" +edition = "2021" + +[dependencies] +async-std = { version = "1.12.0", features = [ "attributes" ] } +chrono = "0.4.31" +clap = { version = "4.4.6", features = [ "cargo" ] } +oo7 = { path = "../" } +rpassword = "7.2.0" diff --git a/keyring-util/src/main.rs b/keyring-util/src/main.rs new file mode 100644 index 000000000..4473459ce --- /dev/null +++ b/keyring-util/src/main.rs @@ -0,0 +1,257 @@ +use std::collections::HashMap; +use std::fmt; +use std::io::Write; +use std::process::{ExitCode, Termination}; + +use clap::parser::ValuesRef; +use clap::{arg, value_parser, Command}; +use oo7::Keyring; + +struct Error(String); + +impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } +} + +impl From for Error { + fn from(_err: oo7::Error) -> Error { + // TODO + Error(String::new()) + } +} + +impl Error { + fn new(s: &str) -> Self { + Self(String::from(s)) + } +} + +impl Termination for Error { + fn report(self) -> ExitCode { + ExitCode::FAILURE + } +} + +#[async_std::main] +async fn main() -> Result<(), Error> { + let cmd = Command::new("keyring-util") + .bin_name("keyring-util") + .subcommand_required(true) + .subcommand( + Command::new("store") + .arg( + arg!(label: