soroban_cli/commands/cache/
clean.rs

1use std::{fs, io::ErrorKind};
2
3use crate::config::{data, locator};
4
5#[derive(thiserror::Error, Debug)]
6pub enum Error {
7    #[error(transparent)]
8    Config(#[from] locator::Error),
9    #[error(transparent)]
10    Data(#[from] data::Error),
11    #[error(transparent)]
12    Io(#[from] std::io::Error),
13}
14
15#[derive(Debug, clap::Parser, Clone)]
16#[group(skip)]
17pub struct Cmd {}
18
19impl Cmd {
20    pub fn run(&self) -> Result<(), Error> {
21        let binding = data::project_dir()?;
22        let dir = binding.data_dir();
23        match fs::remove_dir_all(dir) {
24            Err(err) if err.kind() == ErrorKind::NotFound => (),
25            r => r?,
26        }
27        Ok(())
28    }
29}