chore: Reformat the codebase with the new configration
All checks were successful
Rust CI / Rust CI (pull_request) Successful in 1m52s
Write changelog / write-changelog (push) Successful in 3s
Rust CI / Rust CI (push) Successful in 1m49s

This commit is contained in:
Awiteb 2024-05-06 23:29:48 +03:00
parent c2ce56a7c3
commit 3436e616f8
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F
15 changed files with 78 additions and 62 deletions

View file

@ -19,7 +19,9 @@ use inquire::{Password, PasswordDisplayMode};
use crate::{ use crate::{
vault::{Vault, Vaults}, vault::{Vault, Vaults},
LprsCommand, LprsError, LprsResult, LprsCommand,
LprsError,
LprsResult,
}; };
#[derive(Debug, Args)] #[derive(Debug, Args)]

View file

@ -21,7 +21,9 @@ use inquire::{Password, PasswordDisplayMode};
use crate::{ use crate::{
vault::{Vault, Vaults}, vault::{Vault, Vaults},
LprsCommand, LprsError, LprsResult, LprsCommand,
LprsError,
LprsResult,
}; };
#[derive(Debug, Args)] #[derive(Debug, Args)]
@ -66,13 +68,15 @@ impl LprsCommand for Edit {
// Get the password from stdin or from its value if provided // Get the password from stdin or from its value if provided
let password = match self.password { let password = match self.password {
Some(Some(password)) => Some(password), Some(Some(password)) => Some(password),
Some(None) => Some( Some(None) => {
Some(
Password::new("New vault password:") Password::new("New vault password:")
.without_confirmation() .without_confirmation()
.with_formatter(&|p| "*".repeat(p.chars().count())) .with_formatter(&|p| "*".repeat(p.chars().count()))
.with_display_mode(PasswordDisplayMode::Masked) .with_display_mode(PasswordDisplayMode::Masked)
.prompt()?, .prompt()?,
), )
}
None => None, None => None,
}; };

View file

@ -20,13 +20,15 @@ use clap::Args;
use crate::{ use crate::{
vault::{BitWardenPasswords, Format, Vaults}, vault::{BitWardenPasswords, Format, Vaults},
LprsCommand, LprsError, LprsResult, LprsCommand,
LprsError,
LprsResult,
}; };
#[derive(Debug, Args)] #[derive(Debug, Args)]
#[command(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]
/// Export command, used to export the vaults in `lprs` format or `BitWarden` format. /// Export command, used to export the vaults in `lprs` format or `BitWarden`
/// The exported file will be a json file. /// format. The exported file will be a json file.
pub struct Export { pub struct Export {
/// The path to export to /// The path to export to
path: PathBuf, path: PathBuf,

View file

@ -25,12 +25,15 @@ use clap::Args;
use crate::{ use crate::{
vault::{BitWardenPasswords, Format, Vault, Vaults}, vault::{BitWardenPasswords, Format, Vault, Vaults},
LprsCommand, LprsError, LprsResult, LprsCommand,
LprsError,
LprsResult,
}; };
#[derive(Debug, Args)] #[derive(Debug, Args)]
#[command(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]
/// Import command, used to import vaults from the exported files, `lprs` or `BitWarden` /// Import command, used to import vaults from the exported files, `lprs` or
/// `BitWarden`
pub struct Import { pub struct Import {
/// The file path to import from /// The file path to import from
path: PathBuf, path: PathBuf,

View file

@ -31,7 +31,8 @@ pub mod edit_command;
pub mod export_command; pub mod export_command;
/// Generate command, used to generate a password /// Generate command, used to generate a password
pub mod gen_command; pub mod gen_command;
/// Import command, used to import vaults from the exported files, `lprs` or `BitWarden` /// Import command, used to import vaults from the exported files, `lprs` or
/// `BitWarden`
pub mod import_command; pub mod import_command;
/// List command, used to list the vaults and search /// List command, used to list the vaults and search
pub mod list_command; pub mod list_command;

View file

@ -27,7 +27,8 @@ pub struct Remove {
/// The password index /// The password index
index: NonZeroU64, index: NonZeroU64,
/// Force remove, will not return error if there is no password with this index /// Force remove, will not return error if there is no password with this
/// index
#[arg(short, long)] #[arg(short, long)]
force: bool, force: bool,
} }

View file

@ -24,7 +24,10 @@ pub type Result<T> = result::Result<T, Error>;
pub enum Error { pub enum Error {
#[error("Encryption Error: {0}")] #[error("Encryption Error: {0}")]
Encryption(String), Encryption(String),
#[error("Decryption Error: The given key cannot decrypt the given data. Either the data has been tampered with or the key is incorrect.")] #[error(
"Decryption Error: The given key cannot decrypt the given data. Either the data has been \
tampered with or the key is incorrect."
)]
Decryption, Decryption,
#[error("Wrong Master Password Error: Wrong decryption password")] #[error("Wrong Master Password Error: Wrong decryption password")]
WrongMasterPassword, WrongMasterPassword,

View file

@ -29,10 +29,7 @@
/// #### Output /// #### Output
/// ```rust /// ```rust
/// impl crate::LprsCommand for TestCommands { /// impl crate::LprsCommand for TestCommands {
/// fn run( /// fn run(&self, vault_manager: crate::vault::Vaults) -> crate::LprsResult<()> {
/// &self,
/// vault_manager: crate::vault::Vaults,
/// ) -> crate::LprsResult<()> {
/// match self { /// match self {
/// Self::Test(command) => command.run(vault_manager), /// Self::Test(command) => command.run(vault_manager),
/// Self::Some(command) => command.run(vault_manager), /// Self::Some(command) => command.run(vault_manager),

View file

@ -15,11 +15,12 @@
// along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>. // along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
use clap::Parser;
use inquire::InquireError;
use std::env; use std::env;
use std::process::ExitCode; use std::process::ExitCode;
use clap::Parser;
use inquire::InquireError;
/// The main module of the lprs crate, contains the cli and the commands. /// The main module of the lprs crate, contains the cli and the commands.
pub mod cli; pub mod cli;
/// The errors module, contains the errors and the result type. /// The errors module, contains the errors and the result type.

View file

@ -18,10 +18,9 @@ use std::{fs, path::PathBuf};
use inquire::{validator::Validation, PasswordDisplayMode}; use inquire::{validator::Validation, PasswordDisplayMode};
use passwords::{analyzer, scorer}; use passwords::{analyzer, scorer};
use sha2::Digest;
#[cfg(feature = "update-notify")] #[cfg(feature = "update-notify")]
use reqwest::blocking::Client as BlockingClient; use reqwest::blocking::Client as BlockingClient;
use sha2::Digest;
use crate::{LprsError, LprsResult}; use crate::{LprsError, LprsResult};
@ -64,8 +63,8 @@ pub fn vaults_file() -> LprsResult<PathBuf> {
/// - Its score must be greater than 80.0 /// - Its score must be greater than 80.0
/// ///
/// ## Errors /// ## Errors
/// - There is no errors, just the return type of inquire validator /// - There is no errors, just the return type of inquire validator must be
/// must be Result<Validation, inquire::CustomUserError> /// Result<Validation, inquire::CustomUserError>
pub fn password_validator(password: &str) -> Result<Validation, inquire::CustomUserError> { pub fn password_validator(password: &str) -> Result<Validation, inquire::CustomUserError> {
let analyzed = analyzer::analyze(password); let analyzed = analyzer::analyze(password);
Ok(if analyzed.length() < 15 { Ok(if analyzed.length() < 15 {

View file

@ -14,8 +14,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>. // along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
// This file is not important, it is just a struct that is used to serialize and deserialize the vaults // This file is not important, it is just a struct that is used to serialize and
// from and to the BitWarden format. // deserialize the vaults from and to the BitWarden format.
#![allow(missing_docs)] #![allow(missing_docs)]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View file

@ -14,9 +14,10 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>. // along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
use std::time::{SystemTime, UNIX_EPOCH};
use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyIvInit}; use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyIvInit};
use rand::{rngs::StdRng, Rng, SeedableRng}; use rand::{rngs::StdRng, Rng, SeedableRng};
use std::time::{SystemTime, UNIX_EPOCH};
use crate::{LprsError, LprsResult}; use crate::{LprsError, LprsResult};

View file

@ -33,9 +33,11 @@ pub use bitwarden::*;
/// The vaults format /// The vaults format
pub enum Format { pub enum Format {
/// The lprs format, which is the default format /// The lprs format, which is the default format
/// and is is the result of the serialization/deserialization of the Vaults struct /// and is is the result of the serialization/deserialization of the Vaults
/// struct
Lprs, Lprs,
/// The BitWarden format, which is the result of the serialization/deserialization of the BitWardenPasswords struct /// The BitWarden format, which is the result of the
/// serialization/deserialization of the BitWardenPasswords struct
BitWarden, BitWarden,
} }