shell-cell 1.6.3

Shell-Cell. CLI app to spawn and manage containerized shell environments
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::path::Path;

use crate::{error::UserError, scell::types::SCELL_CUE_FILE_NAME};

const BLUEPRINT: &[u8] = include_bytes!("template_scell.cue");

pub fn init<P: AsRef<Path>>(dir: P) -> color_eyre::Result<()> {
    let path = dir.as_ref().join(SCELL_CUE_FILE_NAME);
    if path.exists() {
        Err(UserError::wrap(format!(
            "`{SCELL_CUE_FILE_NAME}` already exists in `{}`",
            dir.as_ref().display()
        )))?;
    }
    std::fs::write(&path, BLUEPRINT)?;
    println!("Created `{}`", path.display());
    Ok(())
}