1pub mod app;
2pub mod cli;
3pub mod config;
4pub mod image;
5pub mod input;
6pub mod options;
7pub mod renderer;
8pub mod search;
9pub mod theme;
10pub mod ui;
11
12use anyhow::Result;
13use clap::Parser;
14
15use app::App;
16use cli::Cli;
17use config::Config;
18use input::read_input;
19use renderer::ViewDocument;
20use theme::Theme;
21
22pub fn run() -> Result<()> {
23 let cli = Cli::parse();
24
25 if cli.list_themes {
26 for theme in Theme::list_available() {
27 println!("{theme}");
28 }
29 return Ok(());
30 }
31
32 let config = Config::load()?.apply_cli(&cli);
33 let theme = Theme::load(&config.theme, config.icons)?;
34 let input = read_input(cli.input.as_deref(), cli.format)?;
35 let document = ViewDocument::from_input(&input);
36 let mut app = App::new(
37 input.name,
38 input.kind,
39 input.base_dir,
40 document,
41 theme,
42 config.wrap,
43 config.tab_width,
44 );
45
46 ratatui::run(|terminal| app.run(terminal))?;
47 Ok(())
48}