diff --git a/src/credential_manager.rs b/src/credential_manager.rs index e62525c..de233a1 100644 --- a/src/credential_manager.rs +++ b/src/credential_manager.rs @@ -36,16 +36,19 @@ impl Credential { match self.totp_command.clone() { Some(totp_command) => { info!("TOTP command found."); - - let parts = totp_command.split(" ").collect::>(); - let command = parts.first()?.to_string(); - let args = totp_command[command.len()..].to_string(); - - debug!("Executing TOTP command."); - let output = Command::new(command.as_str()) - .arg(args.as_str()) - .output() - .expect("failed to execute process"); + + let output = if cfg!(target_os = "windows") { + Command::new("cmd") + .args(["/C", totp_command.as_str()]) + .output() + .expect("failed to execute process") + } else { + Command::new("sh") + .arg("-c") + .arg(totp_command.as_str()) + .output() + .expect("failed to execute process") + }; Some(String::from_utf8_lossy(&output.stdout).trim().to_string()) }, diff --git a/src/subcommands/login_subcommand.rs b/src/subcommands/login_subcommand.rs index 6c316df..d6484eb 100644 --- a/src/subcommands/login_subcommand.rs +++ b/src/subcommands/login_subcommand.rs @@ -49,8 +49,7 @@ impl Subcommand for LoginSubcommand { let mut file_station = SynologyFileStation::new(url); file_station.login(&credential).await?; - - // TODO; Handle InvalidUserDoesThisFileOperation + credential_manager.set_credential(url, &credential)?; Ok(())