Skip to content

Commit

Permalink
feat: Added running clock: #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
jw committed Feb 18, 2024
1 parent 1a9ff9f commit 059ad9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ itertools = "0.12.1"
log = "0.4.20"
dirs = "5.0.1"
log4rs = "1.3.0"
chrono = "0.4.34"
11 changes: 7 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use chrono::{DateTime, Utc};
use std::path::PathBuf;
use std::{
error::Error,
Expand All @@ -11,7 +12,7 @@ use crossterm::{
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use log::{debug, info, LevelFilter};
use log::{info, LevelFilter};
use log4rs::append::file::FileAppender;
use log4rs::config::{Appender, Logger, Root};
use log4rs::encode::pattern::PatternEncoder;
Expand All @@ -22,6 +23,8 @@ use ratatui::{
};

const LOG_PATTERN: &str = "{d(%Y-%m-%d %H:%M:%S)} | {l} | {f}:{L} | {m}{n}";
const NAME: &str = env!("CARGO_PKG_NAME");
const VERSION: &str = env!("CARGO_PKG_VERSION");

// These type aliases are used to make the code more readable by reducing repetition of the generic
// types. They are not necessary for the functionality of the code.
Expand All @@ -30,8 +33,7 @@ type Result<T> = std::result::Result<T, Box<dyn Error>>;

fn main() -> Result<()> {
initialize_logging();
debug!("Hello there!");
info!("This is brt. Version yokemebob.");
info!("This is {NAME}. Version {}.", VERSION);
let mut terminal = setup_terminal()?;
let result = run(&mut terminal);
restore_terminal(terminal)?;
Expand Down Expand Up @@ -125,6 +127,7 @@ fn ui(frame: &mut Frame) {
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::White))
.border_type(BorderType::Rounded);
let paragraph = Paragraph::new(Line::from("The clock comes here.").centered()).block(block);
let now: DateTime<Utc> = Utc::now();
let paragraph = Paragraph::new(Line::from(now.to_string()).centered()).block(block);
frame.render_widget(paragraph, layout[0]);
}

0 comments on commit 059ad9f

Please sign in to comment.