feat(credential): allow to add credential
This commit is contained in:
39
src/subcommands/credential.rs
Normal file
39
src/subcommands/credential.rs
Normal 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'"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user