diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-10-17 01:27:59 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-10-17 02:21:08 -0400 |
commit | eced41252fcb7983c75ed6fe53d8c804365deecb (patch) | |
tree | 1c4f1acdebb7ef7477691d247e52a7811fd0977d /src/cmd/stream.rs | |
parent | 8fdd26b8cf2bd9f0821f7fbffcaa9e5fa9803607 (diff) | |
download | teleterm-eced41252fcb7983c75ed6fe53d8c804365deecb.tar.gz teleterm-eced41252fcb7983c75ed6fe53d8c804365deecb.zip |
use a real enum for auth types
Diffstat (limited to 'src/cmd/stream.rs')
-rw-r--r-- | src/cmd/stream.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/cmd/stream.rs b/src/cmd/stream.rs index 42a4296..6e7f4e3 100644 --- a/src/cmd/stream.rs +++ b/src/cmd/stream.rs @@ -31,23 +31,26 @@ pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> { pub fn run<'a>(matches: &clap::ArgMatches<'a>) -> super::Result<()> { let auth = if matches.is_present("login-recurse-center") { - let auth = crate::protocol::Auth::RecurseCenter { id: None }; - let id_file = crate::dirs::Dirs::new() - .data_file(&format!("client-oauth-{}", auth.name())); + let id_file = crate::dirs::Dirs::new().data_file(&format!( + "client-oauth-{}", + crate::protocol::AuthType::RecurseCenter.name() + )); let id = std::fs::File::open(id_file).ok().and_then(|mut file| { let mut id = vec![]; file.read_to_end(&mut id).ok().map(|_| { std::string::String::from_utf8_lossy(&id).to_string() }) }); - crate::protocol::Auth::RecurseCenter { id } + crate::protocol::Auth::recurse_center( + id.as_ref().map(std::string::String::as_str), + ) } else { let username = matches .value_of("login-plain") .map(std::string::ToString::to_string) .or_else(|| std::env::var("USER").ok()) .context(crate::error::CouldntFindUsername)?; - crate::protocol::Auth::Plain { username } + crate::protocol::Auth::plain(&username) }; let address = matches.value_of("address").unwrap_or("127.0.0.1:4144"); let (host, address) = crate::util::resolve_address(address)?; |