-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce first super basic init command
This adds a new `init` command to initialize a Vibranium project in either the current directory or a given optional path location: ``` $ vibranium init --path ../../path/to/project ``` If the directories in `path` don't exist, they'll be created recursively. This is a super basic implementation and doesn't account for property interaction for cases like trying to initialize a Vibranium project within a Vibranium project. If the needed directories already exist, Vibranium will just move on.
- Loading branch information
Showing
3 changed files
with
65 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use std::path::{PathBuf}; | ||
use std::fs; | ||
|
||
pub struct CodeGenerator; | ||
|
||
const VIBRANIUM_PROJECT_DIRECTORY: &str = ".vibranium"; | ||
const DEFAULT_CONTRACTS_DIRECTORY: &str = "contracts"; | ||
|
||
impl CodeGenerator { | ||
pub fn new() -> CodeGenerator { | ||
CodeGenerator | ||
} | ||
|
||
pub fn generate_project(&self, project_path: PathBuf) -> Result<(), std::io::Error> { | ||
for directory in vec![VIBRANIUM_PROJECT_DIRECTORY, DEFAULT_CONTRACTS_DIRECTORY] { | ||
let path = project_path.join(directory); | ||
if !path.exists() { | ||
fs::create_dir_all(path)?; | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters