Skip to content

Commit ba959e5

Browse files
committed
Add clear-logs command to empty logs.txt without removing sessions
1 parent 67f7bd6 commit ba959e5

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/bin/cli.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ enum Commands {
4949
ConfigShow,
5050
Env,
5151
HelpAll,
52+
ClearLogs,
5253
}
5354

5455
fn main() -> Result<()> {
@@ -193,7 +194,7 @@ fn main() -> Result<()> {
193194
std::env::consts::ARCH
194195
);
195196
}
196-
Commands::HelpAll => {
197+
Commands::HelpAll => {
197198
println!("Zeta Crypto CLI — command overview:\n");
198199
println!(" gen-mnemonic → Generate new BIP39 mnemonic");
199200
println!(" derive-wallet → Derive wallet from mnemonic");
@@ -214,6 +215,31 @@ fn main() -> Result<()> {
214215
println!(" zeta-cli derive-wallet --phrase \"<mnemonic>\"");
215216
println!(" zeta-cli walletconnect --peer <peer> --action connect");
216217
}
218+
Commands::ClearLogs => {
219+
use std::io::{self, Write};
220+
use std::path::PathBuf;
221+
222+
let mut dir = dirs::home_dir().unwrap_or_else(|| PathBuf::from("."));
223+
dir.push(".zeta_crypto");
224+
let log_path = dir.join("logs.txt");
225+
226+
if log_path.exists() {
227+
print!("This will clear {}. Type 'yes' to confirm: ", log_path.display());
228+
io::stdout().flush().unwrap();
229+
230+
let mut input = String::new();
231+
io::stdin().read_line(&mut input).unwrap();
232+
233+
if input.trim().eq_ignore_ascii_case("yes") {
234+
std::fs::write(&log_path, "").expect("Failed to clear log file");
235+
println!("Logs cleared successfully.");
236+
} else {
237+
println!("Aborted.");
238+
}
239+
} else {
240+
println!("No logs found at {}", log_path.display());
241+
}
242+
}
217243
}
218244

219245
Ok(())

0 commit comments

Comments
 (0)