feat: upate runrs --list

This commit is contained in:
2023-02-23 23:40:44 +08:00
parent e283a210ad
commit c1ae6114b3

View File

@@ -1,15 +1,18 @@
const FILE_META: &'static str = "https://git.hatter.ink/rust-scripts/scriptbase/raw/branch/main/file-meta.txt";
pub fn list_scripts() {
debugging!("Loading URL: {}", FILE_META);
let response = reqwest::blocking::get(FILE_META).unwrap_or_else(|e| {
failure_and_exit!("Get file-meta.txt failed: {}", e);
});
debugging!("Load response: {}", response.status().as_u16());
if response.status().as_u16() != 200 {
failure_and_exit!("Get file-meta.txt failed, status: {}", response.status().as_u16());
}
let text = response.text().unwrap_or_else(|e| {
failure_and_exit!("Get file-meta.txt failed: {}", e);
});
debugging!("Response text: {}", &text);
let mut scripts: Vec<&str> = text.trim().split("\n").collect();
scripts.sort();