2
0
mirror of https://github.com/xvxx/phetch synced 2024-11-10 13:10:54 +00:00
This commit is contained in:
dvkt 2019-11-22 18:26:38 -08:00
parent 0bbaaa54f8
commit 4cd9dced3d

View File

@ -9,6 +9,14 @@ use termion::event::Key;
use termion::input::TermRead; use termion::input::TermRead;
use termion::raw::IntoRawMode; use termion::raw::IntoRawMode;
#[derive(Debug)]
struct Link<'res> {
name: &'res str,
host: &'res str,
port: &'res str,
selector: &'res str,
}
fn main() { fn main() {
let response = phetch("phkt.io", 70, "/links"); let response = phetch("phkt.io", 70, "/links");
let links = parse(&response); let links = parse(&response);
@ -17,15 +25,7 @@ fn main() {
user_input(); user_input();
} }
#[derive(Debug)] fn parse<'res>(response: &'res str) -> Vec<Link> {
struct Link<'a> {
name: &'a str,
host: &'a str,
port: &'a str,
selector: &'a str,
}
fn parse<'a>(response: &'a str) -> Vec<Link> {
let mut links: Vec<Link> = Vec::new(); let mut links: Vec<Link> = Vec::new();
let mut start = true; let mut start = true;
let mut is_link = false; let mut is_link = false;
@ -128,8 +128,7 @@ fn phetch(host: &str, port: i8, selector: &str) -> String {
} }
fn render(buf: &str) { fn render(buf: &str) {
let mut clear = "\x1B[2J\x1B[H"; let clear = ""; //"\x1B[2J\x1B[H";
clear = "";
print!("{}{}", clear, draw(buf)); print!("{}{}", clear, draw(buf));
} }