cargo/src/bin/cargo/commands/login.rs

25 lines
717 B
Rust
Raw Normal View History

2018-12-06 19:17:36 +00:00
use crate::command_prelude::*;
2018-03-07 13:17:10 +00:00
use cargo::ops;
2018-03-12 21:06:04 +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.",
)
.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"))
.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
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
2018-12-20 01:40:01 +00:00
ops::registry_login(
config,
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(())
}