diff --git a/.changeset/new_clean_command.md b/.changeset/new_clean_command.md new file mode 100644 index 000000000000..780151700bd3 --- /dev/null +++ b/.changeset/new_clean_command.md @@ -0,0 +1,11 @@ +--- +@biomejs/biome: minor +--- + +# New `clean` command + +Use this new command to clean after the `biome-logs` directory, and remove all the log files. + +```shell +biome clean +``` diff --git a/crates/biome_cli/src/commands/clean.rs b/crates/biome_cli/src/commands/clean.rs new file mode 100644 index 000000000000..eeb626cb7ffa --- /dev/null +++ b/crates/biome_cli/src/commands/clean.rs @@ -0,0 +1,9 @@ +use crate::{biome_log_dir, CliDiagnostic, CliSession}; +use std::fs::{create_dir, remove_dir_all}; + +/// Runs the clean command +pub fn clean(_cli_session: CliSession) -> Result<(), CliDiagnostic> { + let logs_dir = biome_log_dir(); + remove_dir_all(logs_dir.clone()).and_then(|_| create_dir(logs_dir))?; + Ok(()) +} diff --git a/crates/biome_cli/src/commands/mod.rs b/crates/biome_cli/src/commands/mod.rs index 59a09c51892f..e741ef902a07 100644 --- a/crates/biome_cli/src/commands/mod.rs +++ b/crates/biome_cli/src/commands/mod.rs @@ -26,6 +26,7 @@ use std::path::PathBuf; pub(crate) mod check; pub(crate) mod ci; +pub(crate) mod clean; pub(crate) mod daemon; pub(crate) mod explain; pub(crate) mod format; @@ -346,6 +347,10 @@ pub enum BiomeCommand { doc: Doc, }, + #[bpaf(command)] + /// Clean the logs emitted by the daemon + Clean, + #[bpaf(command("__run_server"), hide)] RunServer { #[bpaf(long("stop-on-disconnect"), hide_usage)] @@ -399,6 +404,7 @@ impl BiomeCommand { | BiomeCommand::Init(_) | BiomeCommand::Explain { .. } | BiomeCommand::RunServer { .. } + | BiomeCommand::Clean { .. } | BiomeCommand::PrintSocket => None, } } diff --git a/crates/biome_cli/src/commands/rage.rs b/crates/biome_cli/src/commands/rage.rs index 53ba17da6f08..ff841bb8a4a3 100644 --- a/crates/biome_cli/src/commands/rage.rs +++ b/crates/biome_cli/src/commands/rage.rs @@ -155,16 +155,9 @@ impl Display for RunningRomeServer { ") .fmt(f)?; - // Version 10.0.0 and below did not include a service version in the pipe name - let version = if version.is_empty() { - "<=10.0.0" - } else { - version.as_str() - }; - markup!( {Section("Server")} - {KeyValuePair("Version", markup!({version}))} + {KeyValuePair("Version", markup!({version.as_str()}))} ) .fmt(f)?; } diff --git a/crates/biome_cli/src/lib.rs b/crates/biome_cli/src/lib.rs index 8f80af323645..d97eba4382e1 100644 --- a/crates/biome_cli/src/lib.rs +++ b/crates/biome_cli/src/lib.rs @@ -76,6 +76,7 @@ impl<'app> CliSession<'app> { BiomeCommand::Rage(_, daemon_logs, formatter, linter) => { commands::rage::rage(self, daemon_logs, formatter, linter) } + BiomeCommand::Clean => commands::clean::clean(self), BiomeCommand::Start(config_path) => commands::daemon::start(self, config_path), BiomeCommand::Stop => commands::daemon::stop(self), BiomeCommand::Check {