Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ color-eyre = "0.6.5"

[dev-dependencies]
tempfile = "3.8"
assert_cmd = "2"
predicates = "3"
159 changes: 159 additions & 0 deletions crates/bargo-core/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
use clap::{Parser, Subcommand, ValueEnum};

/// A developer-friendly CLI wrapper for Noir ZK development
#[derive(Parser)]
#[command(
name = "bargo",
about = "A developer-friendly CLI wrapper for Noir ZK development",
long_about = "bargo consolidates nargo and bb workflows into a single, opinionated tool that 'just works' in a standard Noir workspace.",
version
)]
pub struct Cli {
/// Enable verbose logging (shows underlying commands)
#[arg(short, long, global = true)]
pub verbose: bool,

/// Print commands without executing them
#[arg(long, global = true)]
pub dry_run: bool,

/// Override package name (auto-detected from Nargo.toml)
#[arg(long, global = true)]
pub pkg: Option<String>,

/// Minimize output
#[arg(short, long, global = true)]
pub quiet: bool,

#[command(subcommand)]
pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
/// Check circuit syntax and dependencies
#[command(about = "Run nargo check to validate circuit syntax and dependencies")]
Check,

/// Build circuit (compile + execute to generate bytecode and witness)
#[command(about = "Run nargo execute to generate bytecode and witness files")]
Build,

/// Clean build artifacts
#[command(about = "Remove target directory and all build artifacts")]
Clean {
/// Backend to clean (defaults to all)
#[arg(long, value_enum)]
backend: Option<Backend>,
},

/// Clean and rebuild (equivalent to clean + build)
#[command(about = "Remove target directory and rebuild from scratch")]
Rebuild {
/// Backend to clean (defaults to all)
#[arg(long, value_enum)]
backend: Option<Backend>,
},

/// Cairo/Starknet operations
#[command(about = "Generate Cairo verifiers and interact with Starknet")]
Cairo {
#[command(subcommand)]
command: CairoCommands,
},

/// EVM/Foundry operations
#[command(about = "Generate Solidity verifiers and interact with EVM networks")]
Evm {
#[command(subcommand)]
command: EvmCommands,
},

/// Check system dependencies
#[command(about = "Verify that all required tools are installed and available")]
Doctor,
}

#[derive(Subcommand)]
pub enum CairoCommands {
/// Generate Cairo verifier contract
#[command(about = "Generate Cairo verifier contract for Starknet deployment")]
Gen,

/// Generate Starknet oracle proof
#[command(about = "Generate proof using bb with Starknet oracle hash")]
Prove,

/// Verify Starknet oracle proof
#[command(about = "Verify proof generated with Starknet oracle hash")]
Verify,

/// Generate calldata for proof verification
#[command(about = "Generate calldata JSON for latest proof")]
Calldata,

/// Declare verifier contract on Starknet
#[command(about = "Declare verifier contract on Starknet")]
Declare {
/// Network to declare on (sepolia or mainnet)
#[arg(long, default_value = "sepolia")]
network: String,
},

/// Deploy declared verifier contract
#[command(about = "Deploy declared verifier contract")]
Deploy {
/// Class hash of the declared contract
#[arg(long)]
class_hash: Option<String>,
},

/// Verify proof on-chain
#[command(about = "Verify proof on Starknet using deployed verifier")]
VerifyOnchain {
/// Address of deployed verifier contract
#[arg(short = 'a', long)]
address: Option<String>,
},
}

#[derive(Subcommand)]
pub enum EvmCommands {
/// Generate Solidity verifier contract and Foundry project
#[command(about = "Generate Solidity verifier contract with complete Foundry project setup")]
Gen,

/// Generate Keccak oracle proof
#[command(about = "Generate proof using bb with Keccak oracle hash")]
Prove,

/// Verify Keccak oracle proof
#[command(about = "Verify proof generated with Keccak oracle hash")]
Verify,

/// Deploy verifier contract to EVM network
#[command(about = "Deploy verifier contract using Foundry")]
Deploy {
/// Network to deploy to (mainnet or sepolia)
#[arg(long, default_value = "sepolia")]
network: String,
},

/// Generate calldata for proof verification
#[command(about = "Generate calldata for proof verification using cast")]
Calldata,

/// Verify proof on-chain
#[command(about = "Verify proof on EVM network using deployed verifier")]
VerifyOnchain,
}

#[derive(ValueEnum, Clone, Copy, Debug, PartialEq, Eq)]
pub enum Backend {
/// Barretenberg backend (EVM/Solidity)
Bb,
/// Starknet backend (Cairo)
Starknet,
/// All backends
All,
}
Loading
Loading