From 9b73d152a4e154ac24491b98b3c5736aaa57bc0e Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 27 Dec 2018 17:13:38 +0100 Subject: Implement the pws set subcommand This patch adds the pws set subcommand that writes a PWS slot. --- nitrocli/src/commands.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nitrocli/src/commands.rs') diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs index 125b344..e1c88c8 100644 --- a/nitrocli/src/commands.rs +++ b/nitrocli/src/commands.rs @@ -584,6 +584,15 @@ pub fn pws_get( Ok(()) } +/// Write a PWS slot. +pub fn pws_set(slot: u8, name: &str, login: &str, password: &str) -> Result<()> { + let device = get_device()?; + let pws = get_password_safe(&device)?; + pws + .write_slot(slot, name, login, password) + .map_err(|err| get_error("Could not write PWS slot", &err)) +} + #[cfg(test)] mod tests { use super::*; -- cgit v1.2.1