From a84a85a7a651b9c8933a1aa8e772fcd3396a0a83 Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Sun, 5 May 2024 19:08:17 +0300
Subject: [PATCH 1/9] chore(DX): Add `rust-toolchain.toml`
I see is better to develop the project in `nightly` channel
to take advantage of rustfmt and rust-analyzer features.
---
CONTRIBUTING.md | 5 +++++
rust-toolchain.toml | 13 +++++++++++++
2 files changed, 18 insertions(+)
create mode 100644 rust-toolchain.toml
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6a90c2a..3318937 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -13,6 +13,11 @@ If you have a feature request or an idea for improving lprs, we encourage you to
## Writing Code
Before you start writing code, please open a new issue first to discuss the proposed changes. This will help ensure that your contribution is aligned with the project's goals and that you are not duplicating work that is already in progress or has been completed by someone else.
+### Rust Version
+In the lprs project, we always try to stay on the lowest MSRV possible for compatibility, but the development process relies on the nightly release to get the latest rust-analyzer, rustfmt, and clippy features.
+
+You can check the nightly version used in the project in the `rust-toolchain` file. And the MSRV in the `Cargo.toml` file.
+
### PR title
Your PR will squash and merge, and your PR title will be used as the commit message. Please make sure your PR title is clear and concise.
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
new file mode 100644
index 0000000..523c157
--- /dev/null
+++ b/rust-toolchain.toml
@@ -0,0 +1,13 @@
+[toolchain]
+# We use nightly in development only, the project will always be compliant with
+# the latest stable release and the MSRV as defined in `Cargo.toml` file.
+channel = "nightly-2024-05-05"
+components = [
+ "rustc",
+ "cargo",
+ "rust-std",
+ "rust-src",
+ "rustfmt",
+ "rust-analyzer",
+ "clippy",
+]
--
2.45.2
From 8a2d95a98b07b39ee7d6b97da011be1d3c4decbd Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Sun, 5 May 2024 19:53:28 +0300
Subject: [PATCH 2/9] chore(DX): Update the `CONTRIBUTING.md`
Make it easy to read
---
CONTRIBUTING.md | 62 ++++++++++++++++++++++++++++++++++++-------------
1 file changed, 46 insertions(+), 16 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 3318937..64b1556 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,34 +1,49 @@
# Contributing to lprs
-Thank you for your interest in contributing to lprs! We welcome contributions from the community to help improve the project.
+Thank you for your interest in contributing to lprs! We welcome contributions
+from the community to help improve the project.
## Reporting Issues
-If you encounter any issues or bugs while using lprs, please open a new issue on the Forgejo repository. When reporting an issue, please provide as much detail as possible, including steps to reproduce the issue and any relevant error messages.
+If you encounter any issues or bugs while using lprs, please open a new issue on
+the Forgejo repository. When reporting an issue, please provide as much detail as
+possible, including steps to reproduce the issue and any relevant error messages.
## Feature Requests
-If you have a feature request or an idea for improving lprs, we encourage you to open a new issue on the Forgejo repository. Please describe the feature or improvement in detail and provide any relevant context or examples.
+If you have a feature request or an idea for improving lprs, we encourage you to
+open a new issue on the Forgejo repository. Please describe the feature or
+improvement in detail and provide any relevant context or examples.
## Writing Code
-Before you start writing code, please open a new issue first to discuss the proposed changes. This will help ensure that your contribution is aligned with the project's goals and that you are not duplicating work that is already in progress or has been completed by someone else.
+Before you start writing code, please open a new issue first to discuss the proposed
+changes. This will help ensure that your contribution is aligned with the project's
+goals and that you are not duplicating work that is already in progress or has
+been completed by someone else.
### Rust Version
-In the lprs project, we always try to stay on the lowest MSRV possible for compatibility, but the development process relies on the nightly release to get the latest rust-analyzer, rustfmt, and clippy features.
+In the lprs project, we always try to stay on the lowest MSRV possible for
+compatibility, but the development process relies on the nightly release to get
+the latest rust-analyzer and rustfmt features.
-You can check the nightly version used in the project in the `rust-toolchain` file. And the MSRV in the `Cargo.toml` file.
+You can check the nightly version used in the project in the `rust-toolchain` file.
+And the MSRV in the `Cargo.toml` file.
### PR title
-Your PR will squash and merge, and your PR title will be used as the commit message. Please make sure your PR title is clear and concise.
+Your PR will squash and merge, and your PR title will be used as the commit message.
+Please make sure your PR title is clear and concise.
-The title must follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format. This means that the title should be in the following format:
+The title must follow [Conventional Commits] format. This means that the title
+should be in the following format:
```
():
```
-- The `` is optional, and the `` should be a clear and concise summary of the changes.
-- You should use the imperative, present tense (e.g., "Add feature" instead of "Added feature").
+- The `` is optional, and the `` should be a clear and
+ concise summary of the changes.
+- You should use the imperative, present tense
+ (e.g., "Add feature" instead of "Added feature").
- The `` should be one of the following:
- `feat`: A new feature
- `fix`: A bug fix
@@ -40,7 +55,8 @@ The title must follow [Conventional Commits](https://www.conventionalcommits.org
- `security`: Changes that affect the security of the code
- `perf`: A code change that improves performance
- `test`: Adding missing tests or correcting existing tests
- - `chore`: Changes to the build process or auxiliary tools and libraries such as documentation generation
+ - `chore`: Changes to the build process or auxiliary tools and libraries such
+ as documentation generation
#### Example
```
@@ -49,13 +65,18 @@ The title must follow [Conventional Commits](https://www.conventionalcommits.org
```
### PR description
-Your PR description should provide a clear and concise summary of the changes you have made. It should also include any relevant context or background information that will help the project maintainers understand the purpose of the changes. Make sure to reference the issue that your PR is addressing, and note any breaking changes that your PR introduces.
+Your PR description should provide a clear and concise summary of the changes you
+have made. It should also include any relevant context or background information
+that will help the project maintainers understand the purpose of the changes.
+Make sure to reference the issue that your PR is addressing, and note any breaking
+changes that your PR introduces.
Make sure to explain why you made the changes not just what changes you made.
### Code Style
-Please follow the existing code style and conventions used in the lprs project. This includes:
+Please follow the existing code style and conventions used in the lprs project.
+This includes:
- Using Rust's official formatting tool, `rustfmt`, to format your code.
- Writing clear and concise code with meaningful variable and function names.
@@ -68,14 +89,23 @@ Run the CI before submitting your code. You can run the CI with the following co
just ci
```
-This will run the tests and check the code formatting. If the CI fail, please fix the issues before submitting your code.
+This will run the tests and check the code formatting. If the CI fail, please
+fix the issues before submitting your code.
## Code Review
-All contributions to lprs will go through a code review process. This ensures that the code meets the project's standards and maintains its quality. Please be open to feedback and suggestions from the project maintainers during the code review process.
+All contributions to lprs will go through a code review process.
+This ensures that the code meets the project's standards and maintains its quality.
+Please be open to feedback and suggestions from the project maintainers during
+the code review process.
## License
-By contributing to lprs, you agree that your contributions will be licensed under the project's [LICENSE](LICENSE) file. This means that you are granting lprs the right to use, modify, and distribute your contributions under the terms of the license. wich is GPL-3.0 License.
+By contributing to lprs, you agree that your contributions will be licensed under
+the project's [license](LICENSE). This means that you are granting lprs the
+right to use, modify, and distribute your contributions under the terms of the
+license. Which is GPL-3.0 License.
Happy contributing!
+
+[Conventional Commits]: https://www.conventionalcommits.org/en/v1.0.0/
--
2.45.2
From 1d9e0373e8ca81ac7c16a28bf0e1836f32d66085 Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Sun, 5 May 2024 19:57:45 +0300
Subject: [PATCH 3/9] chore: Remove toolchain override
---
Justfile | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/Justfile b/Justfile
index cc349fb..8b2c4df 100644
--- a/Justfile
+++ b/Justfile
@@ -18,10 +18,9 @@ _default:
# Run the CI
@ci: && msrv
- cargo +stable build -q
- cargo +stable fmt -- --check
- cargo +stable clippy -- -D warnings
- cargo +{{msrv}} clippy -- -D warnings
+ cargo build -q
+ cargo fmt -- --check
+ cargo clippy -- -D warnings
# Check that the current MSRV is correct
@msrv:
--
2.45.2
From 098d5df395b6eed9b446a392be483559a06f3f2f Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Sun, 5 May 2024 20:05:43 +0300
Subject: [PATCH 4/9] chore(CI): Check the MSRV
Because of `rust-toolchain.toml` file, now the rustc will install the
channel that in it, so we need to override the MSRV in the `cargo` command
---
.forgejo/workflows/ci.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml
index 7f31fc7..5d8fbba 100644
--- a/.forgejo/workflows/ci.yml
+++ b/.forgejo/workflows/ci.yml
@@ -13,6 +13,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: https://codeberg.org/TheAwiteb/rust-action@v1.74
+ - name: Check MSRV
+ run: cargo +1.74 build
- name: Build the source code
run: cargo build
- name: Check the code format
--
2.45.2
From e24f33facdb57eb4a8e1e798444c47d8d550acb5 Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Sun, 5 May 2024 20:12:21 +0300
Subject: [PATCH 5/9] chore(lints): Add `rust`/`clippy` lints
This will improve the DX, and make the codebase easy to figuring out
---
Cargo.toml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 896bfe1..5dee409 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,10 +5,10 @@ edition = "2021"
license = "GPL-3.0-only"
authors = ["Awiteb "]
readme = "README.md"
-description = "A local CLI password manager"
+description = "A local CLI password/vault manager"
repository = "https://git.4rs.nl/awiteb/lprs"
rust-version = "1.74.0"
-keywords = ["password", "manager", "CLI"]
+keywords = ["password", "vault", "manager", "CLI"]
categories = ["command-line-utilities"]
[dependencies]
@@ -35,5 +35,55 @@ default = ["update-notify"]
update-notify = ["reqwest/blocking"]
reqwest = ["dep:reqwest"]
+[lints.rust]
+unsafe_code = "forbid"
+missing_docs = "warn"
+
+[lints.clippy]
+# I know is huge, but I like to be explicit, it also provides
+# a better DX for new contributors (Make it easier to understand the codebase).
+# Also, this is a general linting configuration, it's not specific to this project.
+wildcard_imports = "deny"
+manual_let_else = "deny"
+match_bool = "deny"
+match_on_vec_items = "deny"
+or_fun_call = "deny"
+panic = "deny"
+unwrap_used = "deny"
+
+missing_assert_message = "warn"
+missing_const_for_fn = "warn"
+missing_errors_doc = "warn"
+absolute_paths = "warn"
+cast_lossless = "warn"
+clone_on_ref_ptr = "warn"
+cloned_instead_of_copied = "warn"
+dbg_macro = "warn"
+default_trait_access = "warn"
+empty_enum_variants_with_brackets = "warn"
+empty_line_after_doc_comments = "warn"
+empty_line_after_outer_attr = "warn"
+empty_structs_with_brackets = "warn"
+enum_glob_use = "warn"
+equatable_if_let = "warn"
+explicit_iter_loop = "warn"
+filetype_is_file = "warn"
+filter_map_next = "warn"
+flat_map_option = "warn"
+float_cmp = "warn"
+format_push_string = "warn"
+future_not_send = "warn"
+if_not_else = "warn"
+if_then_some_else_none = "warn"
+implicit_clone = "warn"
+inconsistent_struct_constructor = "warn"
+indexing_slicing = "warn"
+iter_filter_is_ok = "warn"
+iter_filter_is_some = "warn"
+iter_not_returning_iterator = "warn"
+manual_is_variant_and = "warn"
+option_if_let_else = "warn"
+option_option = "warn"
+
[profile.release]
strip = true # Automatically strip symbols from the binary.
--
2.45.2
From 17974ce74be99060ce14a286d578e4e78a7c2d62 Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Sun, 5 May 2024 22:42:16 +0300
Subject: [PATCH 6/9] chore(lint): Impl the clippy lints
---
src/cli/add_command.rs | 8 ++++--
src/cli/clean_command.rs | 3 ++-
src/cli/edit_command.rs | 8 ++++--
src/cli/export_command.rs | 31 ++++++++++++++---------
src/cli/gen_command.rs | 1 +
src/cli/import_command.rs | 38 ++++++++++++++++------------
src/cli/list_command.rs | 1 +
src/cli/mod.rs | 20 ++++++++++++++-
src/cli/remove_command.rs | 11 +++++----
src/errors.rs | 10 +++++---
src/macros.rs | 1 -
src/main.rs | 11 ++++++++-
src/traits.rs | 1 +
src/utils.rs | 52 +++++++++++++++++++++++++++------------
src/vault/bitwarden.rs | 20 +++++++++++++++
src/vault/mod.rs | 33 ++++++++++++++++++++-----
16 files changed, 182 insertions(+), 67 deletions(-)
diff --git a/src/cli/add_command.rs b/src/cli/add_command.rs
index d8389a9..579c753 100644
--- a/src/cli/add_command.rs
+++ b/src/cli/add_command.rs
@@ -15,6 +15,7 @@
// along with this program. If not, see .
use clap::Args;
+use inquire::{Password, PasswordDisplayMode};
use crate::{
vault::{Vault, Vaults},
@@ -23,11 +24,14 @@ use crate::{
#[derive(Debug, Args)]
#[command(author, version, about, long_about = None)]
+/// Add command, used to add new vault to the vaults file
pub struct Add {
#[command(flatten)]
vault_info: Vault,
/// The password, if there is no value for it you will prompt it
#[arg(short, long)]
+ // FIXME: I think replacing `Option