fingers

Finger client library in Rust
Log | Files | Refs | README | LICENSE

commit ccb810b233e2e0a00516fa706b656420d06cb220
parent 60233de55abdb240e2ee0ef3e75d6acf3af79cfe
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Wed,  1 Dec 2021 21:42:59 -0800

Add finger client to main

Diffstat:
Msrc/main.rs | 24++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -1,5 +1,25 @@ +use std::process; +use std::{env, io, str}; + fn main() -> Result<(), fingers::Error> { - let result = fingers::finger("alex\r\n", "flounder.online").send()?; - println!("{}", result); + let args: Vec<String> = env::args().collect(); + if args.len() < 2 { + println!("Usage: finger [request]@host or finger://host/request"); + process::exit(1); + } + if args[1].starts_with("finger://") { + println!("{}", fingers::from_url(&args[1])?.send()?); + } + let user: &str; + let host: &str; + let params: Vec<&str> = args[1].split("@").collect(); + if params.len() == 1 { + host = params[0]; + user = ""; + } else { + user = params[0]; + host = params[1]; + } + println!("{}", fingers::finger(user, host).send()?); Ok(()) }