new creates the directory now

unstable
penguin 4 years ago
parent 9d384adecd
commit 74bba47087

@ -1 +0,0 @@
penguin@penguin-arch-home.18919:1598019580

@ -22,6 +22,7 @@ pub enum IglooErrType
IGLOO_CONFIG_FOUND = 3,
IGLOO_UNKNOWN_INST_TYPE = 4,
IGLOO_NEW_CALLED_INSIDE_PRJ = 5,
IGLOO_FOLDER_ALREADY_EXISTS = 6,
}
use IglooInstType::*;
@ -150,7 +151,6 @@ impl Igloo
IGLOO_NULL => res_err = IGLOO_ERR_UNKNOWN,
IGLOO_NEW =>
{
if let ("new", new_matches) = self.cli_conf.subcommand()
{
let prj_name: &str = new_matches.unwrap().value_of("project_name").unwrap();
@ -161,16 +161,25 @@ impl Igloo
if std::path::Path::new(".igloo").exists()
{
res_err = IGLOO_NEW_CALLED_INSIDE_PRJ;
break;
}
if std::path::Path::new(prj_name).exists()
{
// Check if the project folder already exists
// Don't want to accidentally overwrite anything
let prj_path = std::path::Path::new(prj_name);
if prj_path.exists()
{
res_err = IGLOO_FOLDER_ALREADY_EXISTS;
break;
}
let prj_dir = std::fs::create_dir(prj_path).unwrap();
println!("{:?}", prj_path.canonicalize().unwrap());
// populate new dir with defaults!
}
else
{
panic!("Unknown error?");
}
}
IGLOO_FLASH =>

@ -5,7 +5,7 @@ mod igloo;
use clap::{crate_version, crate_description, crate_authors, App, Arg, AppSettings, ArgMatches};
use config::*;
use std::collections::HashMap;
use std::path::Path;
use std::path::{Path, PathBuf};
fn main()
{
let ig = igloo::Igloo::New();

Loading…
Cancel
Save