2018-12-06 19:17:36 +00:00
|
|
|
use crate::command_prelude::*;
|
2018-03-07 13:17:10 +00:00
|
|
|
|
2018-11-25 17:31:27 +00:00
|
|
|
use cargo::ops;
|
2018-03-12 21:06:04 +00:00
|
|
|
|
2022-09-20 18:28:34 +00:00
|
|
|
pub fn cli() -> Command {
|
2018-03-07 13:17:10 +00:00
|
|
|
subcommand("login")
|
2018-03-14 15:17:44 +00:00
|
|
|
.about(
|
|
|
|
"Save an api token from the registry locally. \
|
|
|
|
If token is not specified, it will be read from stdin.",
|
|
|
|
)
|
2021-12-06 03:01:47 +00:00
|
|
|
.arg_quiet()
|
2022-09-20 18:19:46 +00:00
|
|
|
.arg(Arg::new("token").action(ArgAction::Set))
|
2018-03-07 13:17:10 +00:00
|
|
|
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
|
2020-07-06 01:15:07 +00:00
|
|
|
.after_help("Run `cargo help login` for more detailed information.\n")
|
2018-03-07 13:17:10 +00:00
|
|
|
}
|
2018-03-12 21:06:04 +00:00
|
|
|
|
2022-01-04 17:04:50 +00:00
|
|
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
2018-12-20 01:40:01 +00:00
|
|
|
ops::registry_login(
|
|
|
|
config,
|
2022-06-08 20:16:51 +00:00
|
|
|
args.get_one::<String>("token").cloned(),
|
|
|
|
args.get_one::<String>("registry").cloned(),
|
2018-12-20 01:40:01 +00:00
|
|
|
)?;
|
2018-03-12 21:06:04 +00:00
|
|
|
Ok(())
|
|
|
|
}
|