Skip to content

Commit

Permalink
add colors on warnings with colored package
Browse files Browse the repository at this point in the history
  • Loading branch information
remybar committed Mar 10, 2024
1 parent 56f7336 commit c706133
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/sozo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ camino.workspace = true
clap-verbosity-flag = "2.0.1"
clap.workspace = true
clap_complete.workspace = true
colored = "2.1.0"
console.workspace = true
dojo-bindgen.workspace = true
dojo-lang.workspace = true
Expand Down
14 changes: 11 additions & 3 deletions bin/sozo/src/ops/auth.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::{Context, Result};
use colored::Colorize;
use dojo_world::contracts::model::ModelReader;
use dojo_world::contracts::world::WorldContract;
use dojo_world::contracts::WorldContractReader;
Expand Down Expand Up @@ -31,14 +32,21 @@ pub async fn execute(command: AuthCommand, env_metadata: Option<Environment>) ->
let model_address = model.contract_address();

if model_address == FieldElement::ZERO {
println!("[WARN] Unknown model '{}' => IGNORED", model_name);
println!(
"{} Unknown model {} => {}",
"[WARN]".yellow(),
model_name.blue(),
"IGNORED".yellow()
);
} else {
let contract = get_contract_address(&world, mc.contract).await?;

Check warning on line 42 in bin/sozo/src/ops/auth.rs

View check run for this annotation

Codecov / codecov/patch

bin/sozo/src/ops/auth.rs#L30-L42

Added lines #L30 - L42 were not covered by tests

if model_address != contract {
println!(
"[WARN] Wrong address for model '{}' 0x{:x} => IGNORED",
model_name, contract
"{} Wrong address for model {} => {}",
"[WARN]".yellow(),
model_name.blue(),
"IGNORED".yellow()
);
} else {
calls.push(world.grant_writer_getcall(&mc.model, &contract.into()));
Expand Down

0 comments on commit c706133

Please sign in to comment.