This repository has been archived on 2024-10-16. You can view files and clone it, but cannot push or open issues or pull requests.
crock/src/main.rs

38 lines
920 B
Rust
Raw Normal View History

use std::io;
2024-07-09 13:41:25 +02:00
use libpt::cli::clap::Parser;
use ratatui::backend::CrosstermBackend;
use ratatui::crossterm::event::{DisableMouseCapture, EnableMouseCapture};
use ratatui::crossterm::execute;
use ratatui::crossterm::terminal::{
disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen,
2024-07-09 11:58:12 +02:00
};
use ratatui::Terminal;
use self::clock::Clock;
mod clock;
2024-07-09 11:58:12 +02:00
fn main() -> anyhow::Result<()> {
2024-07-09 11:58:12 +02:00
// setup terminal
enable_raw_mode()?;
let mut stdout = io::stdout();
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?;
let clock = Clock::parse();
clock.run(&mut terminal)?;
2024-07-09 11:58:12 +02:00
// restore terminal
disable_raw_mode()?;
execute!(
terminal.backend_mut(),
LeaveAlternateScreen,
DisableMouseCapture
)?;
terminal.show_cursor()?;
Ok(())
2024-03-04 15:14:28 +01:00
}