diff options
Diffstat (limited to 'vendor/gix-credentials/examples/custom-helper.rs')
-rw-r--r-- | vendor/gix-credentials/examples/custom-helper.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/gix-credentials/examples/custom-helper.rs b/vendor/gix-credentials/examples/custom-helper.rs new file mode 100644 index 000000000..9fc0cbf61 --- /dev/null +++ b/vendor/gix-credentials/examples/custom-helper.rs @@ -0,0 +1,24 @@ +use gix_credentials::{program, protocol}; + +/// Run like this `echo url=https://example.com | cargo run --example custom-helper -- get` +pub fn main() -> Result<(), gix_credentials::program::main::Error> { + gix_credentials::program::main( + std::env::args_os().skip(1), + std::io::stdin(), + std::io::stdout(), + |action, context| -> std::io::Result<_> { + match action { + program::main::Action::Get => Ok(Some(protocol::Context { + username: Some("user".into()), + password: Some("pass".into()), + ..context + })), + program::main::Action::Erase => Err(std::io::Error::new( + std::io::ErrorKind::Other, + "Refusing to delete credentials for demo purposes", + )), + program::main::Action::Store => Ok(None), + } + }, + ) +} |