Compare commits
No commits in common. "f022574631bfb1b6a62f95d3259617f302059781" and "2bf856b9a4560d2952cdda040f26e26f0ffd4f4a" have entirely different histories.
f022574631
...
2bf856b9a4
4 changed files with 2 additions and 57 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -228,15 +228,6 @@ dependencies = [
|
||||||
"strsim",
|
"strsim",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clap_complete"
|
|
||||||
version = "4.5.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dd79504325bf38b10165b02e89b4347300f855f273c4cb30c4a3209e6583275e"
|
|
||||||
dependencies = [
|
|
||||||
"clap",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.5.4"
|
version = "4.5.4"
|
||||||
|
@ -729,7 +720,6 @@ dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"cbc",
|
"cbc",
|
||||||
"clap",
|
"clap",
|
||||||
"clap_complete",
|
|
||||||
"directories",
|
"directories",
|
||||||
"inquire",
|
"inquire",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
@ -29,7 +29,6 @@ aes = "0.8.4"
|
||||||
sha2 = "0.10.8"
|
sha2 = "0.10.8"
|
||||||
serde_json = "1.0.116"
|
serde_json = "1.0.116"
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
clap_complete = "4.5.2"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["update-notify"]
|
default = ["update-notify"]
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
// Lprs - A local CLI vault manager
|
|
||||||
// Copyright (C) 2024 Awiteb <a@4rs.nl>
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// 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>.
|
|
||||||
|
|
||||||
use std::io;
|
|
||||||
|
|
||||||
use clap::{Args, CommandFactory};
|
|
||||||
|
|
||||||
use crate::{cli::Cli, vault::Vaults, LprsCommand, LprsResult};
|
|
||||||
|
|
||||||
|
|
||||||
/// Generate shell auto completion
|
|
||||||
#[derive(Debug, Args)]
|
|
||||||
pub struct Completion {
|
|
||||||
/// Shell to generate completion for
|
|
||||||
shell: clap_complete::Shell,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
impl LprsCommand for Completion {
|
|
||||||
fn run(self, _vault_manager: Vaults) -> LprsResult<()> {
|
|
||||||
clap_complete::generate(self.shell, &mut Cli::command(), "lprs", &mut io::stdout());
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,8 +25,6 @@ use crate::{impl_commands, utils, vault::Vaults, LprsCommand, LprsResult};
|
||||||
pub mod add_command;
|
pub mod add_command;
|
||||||
/// Clean command, used to clean the vaults file (remove all vaults)
|
/// Clean command, used to clean the vaults file (remove all vaults)
|
||||||
pub mod clean_command;
|
pub mod clean_command;
|
||||||
/// Generate shell completion
|
|
||||||
pub mod completion_command;
|
|
||||||
/// Edit command, used to edit the vault content
|
/// Edit command, used to edit the vault content
|
||||||
pub mod edit_command;
|
pub mod edit_command;
|
||||||
/// Export command, used to export the vaults
|
/// Export command, used to export the vaults
|
||||||
|
@ -67,11 +65,9 @@ pub enum Commands {
|
||||||
Export(export_command::Export),
|
Export(export_command::Export),
|
||||||
/// Import vaults
|
/// Import vaults
|
||||||
Import(import_command::Import),
|
Import(import_command::Import),
|
||||||
/// Generate shell completion
|
|
||||||
Completion(completion_command::Completion),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_commands!(Commands, Add Remove List Clean Edit Gen Get Export Import Completion);
|
impl_commands!(Commands, Add Remove List Clean Edit Gen Get Export Import);
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
|
@ -120,10 +116,7 @@ impl Cli {
|
||||||
|
|
||||||
self.command.validate_args()?;
|
self.command.validate_args()?;
|
||||||
|
|
||||||
let vault_manager = if matches!(
|
let vault_manager = if matches!(self.command, Commands::Clean(..) | Commands::Gen(..)) {
|
||||||
self.command,
|
|
||||||
Commands::Clean(..) | Commands::Gen(..) | Commands::Completion(..)
|
|
||||||
) {
|
|
||||||
log::info!("Running command that don't need the vault manager");
|
log::info!("Running command that don't need the vault manager");
|
||||||
// Returns empty vault manager for those commands don't need it
|
// Returns empty vault manager for those commands don't need it
|
||||||
Vaults {
|
Vaults {
|
||||||
|
|
Loading…
Reference in a new issue