Skip to content

Commit

Permalink
feat(cli): command clean
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Apr 19, 2024
1 parent 22cf369 commit 45ad820
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
11 changes: 11 additions & 0 deletions .changeset/new_clean_command.md
Original file line number Diff line number Diff line change
@@ -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
```
9 changes: 9 additions & 0 deletions crates/biome_cli/src/commands/clean.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
6 changes: 6 additions & 0 deletions crates/biome_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -399,6 +404,7 @@ impl BiomeCommand {
| BiomeCommand::Init(_)
| BiomeCommand::Explain { .. }
| BiomeCommand::RunServer { .. }
| BiomeCommand::Clean { .. }
| BiomeCommand::PrintSocket => None,
}
}
Expand Down
9 changes: 1 addition & 8 deletions crates/biome_cli/src/commands/rage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
Expand Down
1 change: 1 addition & 0 deletions crates/biome_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 45ad820

Please sign in to comment.