#[cfg(all(feature = "json", not(target_arch = "wasm32")))]
fn main() {
use gilt::console::Console;
use gilt::theme::Theme;
let json = r#"{
"brand.primary": "bold #0078D4",
"brand.success": "bold green",
"brand.warning": "bold yellow",
"brand.error": "bold red",
"brand.muted": "dim grey50"
}"#;
let theme = Theme::from_json_str(json).expect("valid JSON theme");
println!("Loaded theme with {} custom styles", theme.styles.len());
let mut console = Console::builder().width(80).force_terminal(true).build();
console.push_theme(theme);
let primary = console
.get_style("brand.primary")
.expect("brand.primary resolves");
println!("brand.primary = {}", primary);
console.print_text("[brand.primary]gilt themed output[/]");
console.print_text("[brand.success] success[/] build passed");
console.print_text("[brand.warning] warning[/] deprecated API");
console.print_text("[brand.error] error[/] file not found");
console.print_text("[brand.muted] muted [/] verbose detail");
console.pop_theme();
println!("\n(theme popped — 'brand.primary' now falls back to a style parse)");
let path = std::env::temp_dir().join("gilt_example_theme.json");
std::fs::write(&path, json).unwrap();
let mut console2 = Console::builder()
.width(80)
.force_terminal(true)
.theme_from_path(&path)
.build();
let primary2 = console2
.get_style("brand.primary")
.expect("brand.primary loaded from file");
println!(
"\nbrand.primary (loaded from {:?}) = {}",
path.file_name().unwrap(),
primary2
);
console2.print_text("[brand.primary]theme loaded from file![/]");
let _ = std::fs::remove_file(&path);
println!("\n[tip] Set GILT_THEME=/path/to/theme.json to auto-load at Console::new()");
}
#[cfg(not(all(feature = "json", not(target_arch = "wasm32"))))]
fn main() {
eprintln!("This example requires --features json on a non-wasm target");
}