Skip to content

Commit

Permalink
feat(cli): Basic init scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarth committed Jan 10, 2024
1 parent 68218c2 commit 2afe320
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
36 changes: 36 additions & 0 deletions mopro-cli/src/init.rs
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");
}
11 changes: 10 additions & 1 deletion mopro-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use clap::{Parser, Subcommand};

mod init;

/// CLI for multi-platform project management
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
Expand Down Expand Up @@ -57,7 +59,14 @@ fn main() {
adapter, platform, project_name
);
// Implement initialization logic here
println!("Not yet implemented")
// If adapter is 'circom', platform is 'desktop', then do something
if adapter == "circom" && platform == "desktop" {
println!("Initializing circom project for desktop");
init::create_project_structure(project_name);
println!("Project {} created successfully", project_name);
} else {
println!("Not yet implemented")
}
}
Commands::Build { adapter, platform } => {
println!("Building project for platform {}: {}", platform, adapter);
Expand Down

0 comments on commit 2afe320

Please sign in to comment.