feat: Ability to enter password via stdin add&edit #15

Merged
awiteb merged 4 commits from awiteb/fix-6 into master 2024-04-25 00:27:56 +02:00 AGit
10 changed files with 10 additions and 10 deletions
Showing only changes of commit 6666a88cc5 - Show all commits

View file

@ -29,7 +29,7 @@ pub struct Add {
}
impl RunCommand for Add {
fn run(&self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
fn run(self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
if self.vault_info.username.is_none()
&& self.vault_info.password.is_none()
&& self.vault_info.service.is_none()

View file

@ -28,7 +28,7 @@ use crate::{
pub struct Clean {}
impl RunCommand for Clean {
fn run(&self, vault_manager: Vaults<Plain>) -> LprsResult<()> {
fn run(self, vault_manager: Vaults<Plain>) -> LprsResult<()> {
fs::write(vault_manager.vaults_file, "[]").map_err(LprsError::Io)
}
}

View file

@ -47,7 +47,7 @@ pub struct Edit {
}
impl RunCommand for Edit {
fn run(&self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
fn run(self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
let index = self.index.get() as usize;
if let Some(vault) = vault_manager.vaults.get_mut(index - 1) {

View file

@ -34,7 +34,7 @@ pub struct Export {
}
impl RunCommand for Export {
fn run(&self, vault_manager: Vaults<Plain>) -> LprsResult<()> {
fn run(self, vault_manager: Vaults<Plain>) -> LprsResult<()> {
if self
.path
.extension()

View file

@ -45,7 +45,7 @@ pub struct Gen {
}
impl RunCommand for Gen {
fn run(&self, _vault_manager: Vaults<Plain>) -> LprsResult<()> {
fn run(self, _vault_manager: Vaults<Plain>) -> LprsResult<()> {
if self.uppercase || self.lowercase || self.numbers || self.symbols {
println!(
"{}",

View file

@ -35,7 +35,7 @@ pub struct Import {
}
impl RunCommand for Import {
fn run(&self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
fn run(self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
if self.path.exists() {
if self
.path

View file

@ -50,7 +50,7 @@ pub struct List {
}
impl RunCommand for List {
fn run(&self, vault_manager: Vaults<Plain>) -> LprsResult<()> {
fn run(self, vault_manager: Vaults<Plain>) -> LprsResult<()> {
if vault_manager.vaults.is_empty() {
return Err(LprsError::Other(
"Looks like there is no passwords to list".to_owned(),

View file

@ -35,7 +35,7 @@ pub struct Remove {
}
impl RunCommand for Remove {
fn run(&self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
fn run(self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
let index = (self.index.get() - 1) as usize;
if index > vault_manager.vaults.len() {
if !self.force {

View file

@ -63,7 +63,7 @@ macro_rules! create_commands {
#[automatically_derived]
impl $crate::RunCommand for $enum_name{
fn run(&self, vault_manager: $crate::vault::Vaults<$crate::vault::vault_state::Plain>) -> $crate::LprsResult<()> {
fn run(self, vault_manager: $crate::vault::Vaults<$crate::vault::vault_state::Plain>) -> $crate::LprsResult<()> {
match self {
$(
Self::$varint(command) => command.run(vault_manager),

View file

@ -21,5 +21,5 @@ use crate::{
/// Trait to run the command
pub trait RunCommand {
fn run(&self, vault_manager: Vaults<Plain>) -> LprsResult<()>;
fn run(self, vault_manager: Vaults<Plain>) -> LprsResult<()>;
}