Skip to content

Commit 34465bd

Browse files
authored
feat: support live-reload tui when file is changed (#68)
1 parent e808e5c commit 34465bd

File tree

13 files changed

+433
-89
lines changed

13 files changed

+433
-89
lines changed

Cargo.lock

Lines changed: 127 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ clap = { version = "^4", features = ["derive"] }
1616
crossterm = { version = "^0", features = ["use-dev-tty"] }
1717
dirs = "^6"
1818
humansize = "^2"
19+
notify = "^8"
1920
once_cell = "^1"
2021
paste = "^1"
2122
ratatui = "^0"

src/cmd.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ pub struct CommandArgs {
6666
#[clap(long)]
6767
pub max_data_size: Option<usize>,
6868

69+
/// Watch file changes, reload tui if updates
70+
#[clap(long, short = 'R')]
71+
pub live_reload: bool,
72+
6973
/// Write debug logs into this file. The file will be created if not exists.
7074
#[clap(long)]
7175
pub debug: Option<String>,

src/debug.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ pub fn set_file(file: String) {
2020
FILE.set(file).unwrap();
2121
}
2222

23-
pub fn write_logs(msg: String) -> Result<()> {
23+
pub fn write_logs(mut msg: String) -> Result<()> {
24+
msg.push('\n');
2425
let file = match FILE.get() {
2526
Some(file) => file,
2627
None => return Ok(()),

0 commit comments

Comments
 (0)