feat(credential): allow to add credential

This commit is contained in:
grimhilt
2024-02-20 21:24:22 +01:00
parent 1c60560c6e
commit 6a11bb494b
6 changed files with 139 additions and 8 deletions

View File

@@ -0,0 +1,39 @@
use clap::{App, Arg, SubCommand, ArgMatches};
use crate::commands;
use crate::commands::credential::CredentialArgs;
pub fn create() -> App<'static, 'static> {
SubCommand::with_name("credential")
.about("Manage set of credentials")
.subcommand(
SubCommand::with_name("add")
.arg(
Arg::with_name("username")
.required(true)
.takes_value(true)
.value_name("NAME")
.help("The username used to connect to nextcloud"),
)
.arg(
Arg::with_name("password")
.required(false)
.takes_value(true)
.value_name("PASSWORD")
.help("The passowd used to connect to nextcloud (optional)"),
)
.about("Add a new set of credential")
)
}
pub fn handler(args: &ArgMatches<'_>) {
match args.subcommand() {
("add", Some(add_matches)) => {
commands::credential::credential_add(CredentialArgs {
username: add_matches.values_of("username"),
password: add_matches.values_of("password"),
});
}
_ => println!("Invalid or missing subcommand for 'credential'"),
}
}