leo_lang/cli/commands/
clean.rs1use super::*;
18
19#[derive(Parser, Debug)]
21pub struct LeoClean {}
22
23impl Command for LeoClean {
24 type Input = ();
25 type Output = ();
26
27 fn log_span(&self) -> Span {
28 tracing::span!(tracing::Level::INFO, "Leo")
29 }
30
31 fn prelude(&self, _: Context) -> Result<Self::Input> {
32 Ok(())
33 }
34
35 fn apply(self, context: Context, _: Self::Input) -> Result<Self::Output> {
36 let path = context.dir()?;
37
38 let outputs_path = path.join(leo_package::OUTPUTS_DIRECTORY);
40 std::fs::remove_dir_all(&outputs_path)
41 .map_err(|e| PackageError::failed_to_remove_directory(outputs_path.display(), e))?;
42 tracing::info!("🧹 Cleaned the outputs directory {}", outputs_path.display().to_string().dimmed());
43
44 let build_path = path.join(leo_package::BUILD_DIRECTORY);
46 std::fs::remove_dir_all(&build_path)
47 .map_err(|e| PackageError::failed_to_remove_directory(build_path.display(), e))?;
48 tracing::info!("🧹 Cleaned the build directory {}", build_path.display().to_string().dimmed());
49
50 Ok(())
51 }
52}