-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use std::fs; | ||
use std::io::Write; | ||
use std::path::Path; | ||
|
||
pub fn create_project_structure(project_name: &str) { | ||
// Create the base project directory | ||
let base_dir = Path::new(project_name); | ||
if !base_dir.exists() { | ||
fs::create_dir(base_dir).expect("Failed to create project directory"); | ||
} | ||
|
||
// Create subdirectories | ||
let subdirs = ["circuits", "src", "test"]; | ||
for subdir in subdirs.iter() { | ||
let dir_path = base_dir.join(subdir); | ||
fs::create_dir_all(&dir_path).expect("Failed to create subdirectory"); | ||
} | ||
|
||
// Create files in their respective directories | ||
let file_contents = [ | ||
("circuits/hello.circom", "template content for hello.circom"), | ||
("src/core.rs", "// Core module content"), | ||
("test/hello-world.rs", "// Test cases for hello world"), | ||
]; | ||
|
||
for (file_path, content) in file_contents.iter() { | ||
let full_path = base_dir.join(file_path); | ||
let mut file = fs::File::create(&full_path).expect("Failed to create file"); | ||
writeln!(file, "{}", content).expect("Failed to write to file"); | ||
} | ||
|
||
// Create README.md | ||
let readme_path = base_dir.join("README.md"); | ||
let mut readme = fs::File::create(readme_path).expect("Failed to create README.md"); | ||
writeln!(readme, "# Project: {}", project_name).expect("Failed to write to README.md"); | ||
} |
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