wip: currently rewriting the project as a full stack application tangled.org/kacaii.dev/sigo
gleam

:art: add colored output to some messages

+17 -8
+11 -7
dev/app_dev.gleam
··· 7 7 import gleam/int 8 8 import gleam/io 9 9 import gleam/list 10 + import gleam_community/ansi 10 11 import pog 11 12 12 13 /// Number of generated user accounts ··· 29 30 } 30 31 31 32 fn dummy_data(ctx: Context) { 32 - io.println("  Inserindo usuários..") 33 + io.println(ansi.green(" ") <> " Inserindo usuários..") 33 34 34 35 let dummy_users = 35 36 list.map(list.range(1, n_user_accounts), fn(_) { dummy.random_user(ctx.db) }) 36 37 37 38 // BRIGADES ------------------------------------------------------------------ 38 - io.println("  Formando equipes..") 39 + io.println(ansi.green(" ") <> " Formando equipes..") 39 40 40 41 let assigned_members = 41 42 list.shuffle(dummy_users) ··· 51 52 list.shuffle(dummy_brigades) 52 53 |> list.sized_chunk(n_occurences / n_brigades) 53 54 54 - io.println(" 󱐁 Registrando ocorrências..") 55 + io.println(ansi.green(" ") <> "󱐁 Registrando ocorrências..") 55 56 56 57 let dummy_occurrences = 57 58 list.map(list.range(1, n_occurences), fn(_) { ··· 73 74 dummy_brigades 74 75 |> list.length 75 76 |> int.to_string 77 + |> ansi.green 76 78 77 79 let n_created_users_str = 78 80 dummy_users 79 81 |> list.length 80 82 |> int.to_string 83 + |> ansi.green 81 84 82 85 let n_created_occ_str = 83 86 dummy_occurrences 84 87 |> list.length 85 88 |> int.to_string 89 + |> ansi.green 86 90 87 - io.println("  Prontinho!") 88 - io.println("Total de " <> n_created_users_str <> " usuários criados.  ") 89 - io.println("Total de " <> n_created_brigades_str <> " equipes criadas.  ") 90 - io.println("Total de " <> n_created_occ_str <> " ocorrências criadas.  ") 91 + io.println(ansi.green(" ") <> " Prontinho!") 92 + io.println("Total de " <> n_created_users_str <> " usuários criados") 93 + io.println("Total de " <> n_created_brigades_str <> " equipes criadas") 94 + io.println("Total de " <> n_created_occ_str <> " ocorrências criadas") 91 95 } 92 96 93 97 fn setup_context() {
+1
gleam.toml
··· 34 34 simplifile = ">= 2.3.0 and < 3.0.0" 35 35 group_registry = ">= 1.0.0 and < 2.0.0" 36 36 gleam_crypto = ">= 1.5.1 and < 2.0.0" 37 + gleam_community_ansi = ">= 1.4.3 and < 2.0.0" 37 38 38 39 [dev-dependencies] 39 40 gleeunit = ">= 1.0.0 and < 2.0.0"
+1
manifest.toml
··· 82 82 squirrel = { version = ">= 4.4.1 and < 5.0.0" } 83 83 wisp = { version = ">= 2.0.0 and < 3.0.0" } 84 84 youid = { version = ">= 1.5.1 and < 2.0.0" } 85 + gleam_community_ansi = { version = ">= 1.4.3 and < 2.0.0" }
+4 -1
src/app.gleam
··· 23 23 import gleam/json 24 24 import gleam/list 25 25 import gleam/result 26 + import gleam_community/ansi 26 27 import pog 27 28 import wisp 28 29 import wisp/simulate ··· 120 121 |> simulate.json_body(json.object([#("key", json.string("admin"))])) 121 122 |> http_router.handle_request(request: _, ctx:) 122 123 123 - io.println(" Administrador cadastrado com sucesso!") 124 + "Administrador cadastrado com sucesso!" 125 + |> ansi.green 126 + |> io.println 124 127 }