1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#![allow(clippy::useless_format)]

mod commands {
    pub mod init;
    pub mod package;
}
pub(crate) mod console {
    mod command;
    pub mod config;
    pub mod error;
    pub mod messages;
    pub mod spinners;
    pub mod step;
    pub mod theme;

    pub use command::*;
    pub use config::*;
    pub use error::*;
    pub use messages::*;
    pub use spinners::*;
    pub use step::*;
    pub use theme::*;
}

mod bindings;
mod lib_type;
mod metadata;
mod path;
mod swiftpackage;
mod targets;
mod templating;
mod xcframework;

pub use crate::console::error::Result;
pub use crate::console::Config;
pub use commands::*;
pub use lib_type::LibType;
pub use targets::*;

use std::fs::{create_dir, remove_dir_all};
use std::io;
use std::path::Path;

fn recreate_dir<P>(dir: P) -> crate::Result<()>
where
    P: AsRef<Path>,
{
    match remove_dir_all(&dir) {
        Err(e) if e.kind() != io::ErrorKind::NotFound => Err(e.into()),
        _ => create_dir(&dir).map_err(|e| e.into()),
    }
}