Skip to content

In this section, let’s just cover the contents of, and

The file is the entry point of the application. Here’s the complete file:

pub mod action;
pub mod app;
pub mod cli;
pub mod components;
pub mod config;
pub mod tui;
pub mod utils;
use clap::Parser;
use cli::Cli;
use color_eyre::eyre::Result;
use crate::{
utils::{initialize_logging, initialize_panic_handler, version},
async fn tokio_main() -> Result<()> {
let args = Cli::parse();
let mut app = App::new(args.tick_rate, args.frame_rate)?;;
async fn main() -> Result<()> {
if let Err(e) = tokio_main().await {
eprintln!("{} error: Something went wrong", env!("CARGO_PKG_NAME"));
} else {

In essence, the main function creates an instance of App and calls, which runs the ”handle event -> update state -> draw” loop. We will talk more about this in a later section.

This file incorporates some key features that are not necessarily related to ratatui, but in my opinion, essential for any Terminal User Interface (TUI) program:

  • Command Line Argument Parsing (clap)
  • XDG Base Directory Specification
  • Logging
  • Panic Handler

These are described in more detail in the section.