You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
phetch/src/main.rs

40 lines
1.0 KiB
Rust

5 years ago
#![allow(unused_must_use)]
extern crate termion;
5 years ago
mod fetch;
mod gopher;
mod menu;
5 years ago
mod types;
5 years ago
mod ui;
5 years ago
5 years ago
use gopher::Type;
5 years ago
fn main() {
5 years ago
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
5 years ago
print_usage();
5 years ago
return;
}
5 years ago
let host = args.get(1).unwrap();
5 years ago
let port = "70".to_string();
5 years ago
let port = args.get(2).unwrap_or(&port);
5 years ago
let selector = "/".to_string();
5 years ago
let selector = args.get(3).unwrap_or(&selector);
5 years ago
if host == "--help" || host == "-h" || host == "-help" {
5 years ago
print_usage();
5 years ago
return;
}
5 years ago
let mut ui = ui::UI::new();
5 years ago
let url = format!("{}:{}/1/{}", host, port, selector);
ui.load(url);
5 years ago
ui.run();
5 years ago
}
5 years ago
fn print_usage() {
5 years ago
println!("\x1B[93;1musage:\x1B[0m phetch <gopher-url> # Show GopherHole at URL");
println!(" phetch -raw <gopher-url> # Print raw Gopher response.");
println!(" phetch -help # Show this screen.");
println!(" phetch -version # Show phetch version.");
5 years ago
}