aors 0.4.0

Useful rs tools for Advent of Code
Documentation
use crate::commands::{cmd, mkdir, touch};
use crate::ANSWER_FOLDER;
use std::error::Error;
use std::fs;

const GITIGNORE: &str = "
# Eric Wastl wishes for users not to share their puzzle input
/inputs/*
/input_examples/*

# Generated by Cargo
# will have compiled files and executables
/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk
";

pub fn init() -> Result<(), Box<dyn Error>> {
    cmd("cargo", &["init"]);
    cmd("cargo", &["add", "aors"]);
    fs::remove_file("src/main.rs")?;
    fs::remove_file(".gitignore")?;

    mkdir("inputs");
    mkdir("input_examples");
    mkdir(ANSWER_FOLDER);
    mkdir("src/bin/helpers");

    touch(
        "src/bin/helpers/mod.rs",
        "#[allow(dead_code)]",
        "failed to create helpers module",
    );

    touch(".gitignore", GITIGNORE, "failed to create .gitignore");

    touch("src/main.rs", "fn main() {}", "failed to create main.rs");

    Ok(())
}