Skip to content

Commit

Permalink
fix: simplify ui for better readability of sozo output (#2656)
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm authored Nov 7, 2024
1 parent c364d13 commit dddac32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
21 changes: 5 additions & 16 deletions bin/sozo/src/commands/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use dojo_world::ResourceType;
use scarb::core::Config;
use serde::Serialize;
use tabled::settings::object::Cell;
use tabled::settings::{Color, Theme};
use tabled::settings::{Color, Style};
use tabled::{Table, Tabled};
use tracing::trace;

Expand Down Expand Up @@ -66,7 +66,7 @@ impl std::fmt::Display for ResourceStatus {
ResourceStatus::Updated => write!(f, "{}", "Updated".yellow()),
ResourceStatus::Synced => write!(f, "{}", "Synced".green()),
ResourceStatus::DirtyLocalPerms => write!(f, "{}", "Dirty local perms".yellow()),
ResourceStatus::MigrationSkipped => write!(f, "{}", "Migration skipped".black()),
ResourceStatus::MigrationSkipped => write!(f, "{}", "Migration skipped".bright_black()),
}
}
}
Expand Down Expand Up @@ -149,7 +149,7 @@ impl std::fmt::Display for GranteeSource {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
GranteeSource::Local => write!(f, "{}", "Local".blue()),
GranteeSource::Remote => write!(f, "{}", "Remote".black()),
GranteeSource::Remote => write!(f, "{}", "Remote".bright_black()),
GranteeSource::Synced => write!(f, "{}", "Synced".green()),
}
}
Expand Down Expand Up @@ -439,7 +439,7 @@ where
}

let mut table = Table::new(data);
table.with(halloween());
table.with(Style::psql());

if let Some(color) = color {
table.modify(Cell::new(0, 0), color);
Expand All @@ -452,17 +452,6 @@ where
println!("{table}\n");
}

pub fn halloween() -> Theme {
let mut style = Theme::default();
style.set_borders_vertical('💀');
style.set_borders_left('💀');
style.set_borders_right('💀');

style.set_borders_corner_top_left('🎃');

style
}

/// Pretty prints a TOML string.
fn pretty_print_toml(str: &str) {
for line in str.lines() {
Expand Down Expand Up @@ -492,7 +481,7 @@ fn pretty_print_toml(str: &str) {
_ => value.white(),
};

println!("{}: {}", key.black(), colored_values);
println!("{}: {}", key.bright_black(), colored_values);
} else {
println!("{}", line);
}
Expand Down
10 changes: 5 additions & 5 deletions bin/sozo/src/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl MigrateArgs {
);

let MigrationResult { manifest, has_changes } =
migration.migrate(&mut spinner).await.context("💀 Migration failed.")?;
migration.migrate(&mut spinner).await.context("Migration failed.")?;

spinner.update_text("Writing manifest...");
ws.write_manifest_profile(manifest).context("🪦 Failed to write manifest.")?;
Expand All @@ -83,7 +83,7 @@ impl MigrateArgs {
let (symbol, end_text) = if has_changes {
("⛩️ ", format!("Migration successful with world at address {}", colored_address))
} else {
("🎃", format!("No changes for world at address {:#066x}", world_address))
("🪨 ", format!("No changes for world at address {:#066x}", world_address))
};

spinner.stop_and_persist_boxed(symbol, end_text);
Expand All @@ -106,11 +106,11 @@ async fn print_banner(ws: &Workspace<'_>, starknet: &StarknetOptions) -> Result<
let (provider, rpc_url) = starknet.provider(profile_config.env.as_ref())?;

let chain_id = provider.chain_id().await?;
let chain_id = parse_cairo_short_string(&chain_id)
.with_context(|| "💀 Cannot parse chain_id as string")?;
let chain_id =
parse_cairo_short_string(&chain_id).with_context(|| "Cannot parse chain_id as string")?;

let banner = Banner {
profile: ws.current_profile().expect("💀 Scarb profile should be set.").to_string(),
profile: ws.current_profile().expect("Scarb profile should be set.").to_string(),
chain_id,
rpc_url,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/sozo/ops/src/migration_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl MigrationUi {
/// Returns a new instance with the default frames.
pub fn new(text: Option<&'static str>) -> Self {
if let Some(text) = text {
let frames = spinner!(["⛩️ ", "🎃", "👻", "🧟", "💀"], 500);
let frames = spinner!(["⛩️ ", "🥷 ", "🗡️ "], 500);
let spinner = Spinner::new(frames.clone(), text, None);
Self { spinner, default_frames: frames, silent: false }
} else {
Expand Down

0 comments on commit dddac32

Please sign in to comment.