1use crate::console::Console;
4use crate::panel::Panel;
5
6use std::fmt::Debug;
7
8#[derive(Debug, Clone, Default)]
10pub struct InspectConfig {
11 pub help: bool,
13 pub methods: bool,
15}
16
17pub fn inspect<T: Debug>(obj: &T, config: InspectConfig) {
21 let console = Console::new();
22 let debug_str = format!("{:#?}", obj);
23
24 let type_name = std::any::type_name::<T>();
26 let title = format!("Inspect: [bold cyan]{}[/]", type_name);
27
28 let mut chunks = Vec::new();
29 chunks.push(format!("Type: [green]{}[/]", type_name));
30
31 if config.help {
32 chunks.push(
33 "\n[dim]Docstrings are not available in Rust runtime introspection.[/dim]".to_string(),
34 );
35 }
36
37 chunks.push(format!("\n[bold]Value:[/]\n{}", debug_str));
38
39 let content = chunks.join("\n");
40 let panel = Panel::new(crate::markup::parse(&content))
41 .title(&title)
42 .style(crate::style::Style::new().foreground(crate::style::Color::Blue));
43
44 console.print_renderable(&panel);
45}