Skip to content

Commit

Permalink
auto merge of #973 : alexcrichton/cargo/issue-968, r=huonw
Browse files Browse the repository at this point in the history
Closes #968
  • Loading branch information
bors committed Nov 25, 2014
2 parents 7e01c2c + 245c634 commit f936f35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

extern crate serialize;
#[phase(plugin, link)] extern crate log;

extern crate cargo;
#[phase(plugin, link)] extern crate cargo;

use std::collections::TreeSet;
use std::os;
Expand Down
24 changes: 16 additions & 8 deletions src/bin/login.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::io;

use cargo::ops;
use cargo::core::{MultiShell};
use cargo::core::{MultiShell, SourceId, Source};
use cargo::sources::RegistrySource;
use cargo::util::{CliResult, CliError};
use cargo::util::{CliResult, CliError, Config};

#[deriving(Decodable)]
struct Options {
Expand All @@ -30,12 +30,20 @@ pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>
let token = match options.arg_token.clone() {
Some(token) => token,
None => {
let default = RegistrySource::url().unwrap().to_string();
let host = options.flag_host.unwrap_or(default);
println!("please visit {}/me and paste the API Token below", host);
try!(io::stdin().read_line().map_err(|e| {
CliError::from_boxed(box e, 101)
}))
let err = (|| {
let config = try!(Config::new(shell, None, None));
let src = try!(SourceId::for_central());
let mut src = RegistrySource::new(&src, &config);
try!(src.update());
let config = try!(src.config());
let host = options.flag_host.clone().unwrap_or(config.api);
println!("please visit {}me and paste the API Token below",
host);
let line = try!(io::stdin().read_line());
Ok(line)
})();

try!(err.map_err(|e| CliError::from_boxed(e, 101)))
}
};

Expand Down

0 comments on commit f936f35

Please sign in to comment.