this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

remove unused package; organize main; add 'please provide a search term' printout if no search arg is provided

nuv f4889aa8 e1d44a65

+46 -38
+3 -1
gleam.toml
··· 2 2 version = "1.0.0" 3 3 target = "javascript" 4 4 5 + [javascript] 6 + runtime = "bun" 7 + 5 8 # Fill out these fields if you intend to generate HTML documentation or publish 6 9 # your project to the Hex package manager. 7 10 # ··· 17 20 gleam_stdlib = ">= 0.44.0 and < 2.0.0" 18 21 gleam_http = ">= 4.1.1 and < 5.0.0" 19 22 shellout = ">= 1.7.0 and < 2.0.0" 20 - html_parser = ">= 1.0.1 and < 2.0.0" 21 23 splitter = ">= 1.0.0 and < 2.0.0" 22 24 argv = ">= 1.0.2 and < 2.0.0" 23 25 gleam_fetch = ">= 1.3.0 and < 2.0.0"
+1 -3
manifest.toml
··· 6 6 { name = "gleam_fetch", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_javascript", "gleam_stdlib"], otp_app = "gleam_fetch", source = "hex", outer_checksum = "2CBF9F2E1C71AEBBFB13A9D5720CD8DB4263EB02FE60C5A7A1C6E17B0151C20C" }, 7 7 { name = "gleam_http", version = "4.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "DD0271B32C356FB684EC7E9F48B1E835D0480168848581F68983C0CC371405D4" }, 8 8 { name = "gleam_javascript", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_javascript", source = "hex", outer_checksum = "EF6C77A506F026C6FB37941889477CD5E4234FCD4337FF0E9384E297CB8F97EB" }, 9 - { name = "gleam_stdlib", version = "0.62.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "DC8872BC0B8550F6E22F0F698CFE7F1E4BDA7312FDEB40D6C3F44C5B706C8310" }, 9 + { name = "gleam_stdlib", version = "0.62.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "0080706D3A5A9A36C40C68481D1D231D243AF602E6D2A2BE67BA8F8F4DFF45EC" }, 10 10 { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" }, 11 - { name = "html_parser", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "html_parser", source = "hex", outer_checksum = "EEC0A3891CE99A49A8BB99086A06F56441D2ACF9436CE33ADBE51CE277D2D607" }, 12 11 { name = "shellout", version = "1.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "1BDC03438FEB97A6AF3E396F4ABEB32BECF20DF2452EC9A8C0ACEB7BDDF70B14" }, 13 12 { name = "splitter", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "128FC521EE33B0012E3E64D5B55168586BC1B9C8D7B0D0CA223B68B0D770A547" }, 14 13 ] ··· 20 19 gleam_javascript = { version = ">= 1.0.0 and < 2.0.0" } 21 20 gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } 22 21 gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 23 - html_parser = { version = ">= 1.0.1 and < 2.0.0" } 24 22 shellout = { version = ">= 1.7.0 and < 2.0.0" } 25 23 splitter = { version = ">= 1.0.0 and < 2.0.0" }
+42 -34
src/condition_overload.gleam
··· 11 11 import splitter 12 12 13 13 pub fn main() { 14 - use search <- result.try( 14 + let search = 15 15 argv.load().arguments 16 - |> list.reduce(fn(acc, x) { acc <> " " <> x }), 17 - ) 18 - let search = string.lowercase(search) 16 + |> list.reduce(fn(acc, x) { acc <> " " <> x }) 17 + |> result.map(string.lowercase) 18 + case search { 19 + Error(_) -> io.println("Please provide a search term") 20 + Ok(search) -> { 21 + do_search(search) 22 + } 23 + } 24 + } 19 25 20 - Ok( 21 - [ 22 - "https://wiki.warframe.com/w/Condition_Overload_%28Mechanic%29?action=edit&section=7", 23 - "https://wiki.warframe.com/w/Condition_Overload_%28Mechanic%29?action=edit&section=8", 24 - ] 25 - |> list.map(get_gun_page_data) 26 - |> promise.await_list() 27 - |> promise.map(result.values) 28 - |> promise.map(list.flatten) 29 - |> promise.map( 30 - list.filter(_, fn(item) { 31 - item.names 32 - |> list.any(fn(name) { 33 - let lower = string.lowercase(name) 34 - string.contains(lower, search) 35 - }) 36 - }), 37 - ) 38 - |> promise.map(fn(rows) { 39 - case list.length(rows) { 40 - 0 -> io.println("\"" <> search <> "\" could not be found") 41 - _ -> { 42 - rows 43 - |> list.take(4) 44 - |> list.map(fn(x) { format_row(x) }) 45 - |> list.reduce(fn(acc, x) { acc <> " || " <> x }) 46 - |> result.map(io.println) 47 - |> result.unwrap_both() 48 - } 49 - } 26 + // do search and print result if any 27 + // 28 + fn do_search(search: String) { 29 + [ 30 + "https://wiki.warframe.com/w/Condition_Overload_%28Mechanic%29?action=edit&section=7", 31 + "https://wiki.warframe.com/w/Condition_Overload_%28Mechanic%29?action=edit&section=8", 32 + ] 33 + |> list.map(get_gun_page_data) 34 + |> promise.await_list() 35 + |> promise.map(result.values) 36 + |> promise.map(list.flatten) 37 + |> promise.map( 38 + list.filter(_, fn(item) { 39 + item.names 40 + |> list.any(fn(name) { 41 + let lower = string.lowercase(name) 42 + string.contains(lower, search) 43 + }) 50 44 }), 51 45 ) 46 + |> promise.map(fn(rows) { 47 + case list.length(rows) { 48 + 0 -> io.println("\"" <> search <> "\" could not be found") 49 + _ -> { 50 + rows 51 + |> list.take(4) 52 + |> list.map(format_row) 53 + |> list.reduce(fn(acc, x) { acc <> " || " <> x }) 54 + |> result.map(io.println) 55 + |> result.unwrap_both() 56 + } 57 + } 58 + }) 59 + Nil 52 60 } 53 61 54 62 // format row into human readable string