Skip to content

Commit 869a533

Browse files
committed
phase-2: cleanup helpers, dedup enum, clippy green
1 parent 86422b2 commit 869a533

File tree

15 files changed

+795
-667
lines changed

15 files changed

+795
-667
lines changed

Cargo.lock

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ color-eyre = "0.6.5"
1212

1313
[dev-dependencies]
1414
tempfile = "3.8"
15+
assert_cmd = "2"
16+
predicates = "3"

crates/bargo-core/src/cli.rs

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
use clap::{Parser, Subcommand, ValueEnum};
2+
3+
/// A developer-friendly CLI wrapper for Noir ZK development
4+
#[derive(Parser)]
5+
#[command(
6+
name = "bargo",
7+
about = "A developer-friendly CLI wrapper for Noir ZK development",
8+
long_about = "bargo consolidates nargo and bb workflows into a single, opinionated tool that 'just works' in a standard Noir workspace.",
9+
version
10+
)]
11+
pub struct Cli {
12+
/// Enable verbose logging (shows underlying commands)
13+
#[arg(short, long, global = true)]
14+
pub verbose: bool,
15+
16+
/// Print commands without executing them
17+
#[arg(long, global = true)]
18+
pub dry_run: bool,
19+
20+
/// Override package name (auto-detected from Nargo.toml)
21+
#[arg(long, global = true)]
22+
pub pkg: Option<String>,
23+
24+
/// Minimize output
25+
#[arg(short, long, global = true)]
26+
pub quiet: bool,
27+
28+
#[command(subcommand)]
29+
pub command: Commands,
30+
}
31+
32+
#[derive(Subcommand)]
33+
pub enum Commands {
34+
/// Check circuit syntax and dependencies
35+
#[command(about = "Run nargo check to validate circuit syntax and dependencies")]
36+
Check,
37+
38+
/// Build circuit (compile + execute to generate bytecode and witness)
39+
#[command(about = "Run nargo execute to generate bytecode and witness files")]
40+
Build,
41+
42+
/// Clean build artifacts
43+
#[command(about = "Remove target directory and all build artifacts")]
44+
Clean {
45+
/// Backend to clean (defaults to all)
46+
#[arg(long, value_enum)]
47+
backend: Option<Backend>,
48+
},
49+
50+
/// Clean and rebuild (equivalent to clean + build)
51+
#[command(about = "Remove target directory and rebuild from scratch")]
52+
Rebuild {
53+
/// Backend to clean (defaults to all)
54+
#[arg(long, value_enum)]
55+
backend: Option<Backend>,
56+
},
57+
58+
/// Cairo/Starknet operations
59+
#[command(about = "Generate Cairo verifiers and interact with Starknet")]
60+
Cairo {
61+
#[command(subcommand)]
62+
command: CairoCommands,
63+
},
64+
65+
/// EVM/Foundry operations
66+
#[command(about = "Generate Solidity verifiers and interact with EVM networks")]
67+
Evm {
68+
#[command(subcommand)]
69+
command: EvmCommands,
70+
},
71+
72+
/// Check system dependencies
73+
#[command(about = "Verify that all required tools are installed and available")]
74+
Doctor,
75+
}
76+
77+
#[derive(Subcommand)]
78+
pub enum CairoCommands {
79+
/// Generate Cairo verifier contract
80+
#[command(about = "Generate Cairo verifier contract for Starknet deployment")]
81+
Gen,
82+
83+
/// Generate Starknet oracle proof
84+
#[command(about = "Generate proof using bb with Starknet oracle hash")]
85+
Prove,
86+
87+
/// Verify Starknet oracle proof
88+
#[command(about = "Verify proof generated with Starknet oracle hash")]
89+
Verify,
90+
91+
/// Generate calldata for proof verification
92+
#[command(about = "Generate calldata JSON for latest proof")]
93+
Calldata,
94+
95+
/// Declare verifier contract on Starknet
96+
#[command(about = "Declare verifier contract on Starknet")]
97+
Declare {
98+
/// Network to declare on (sepolia or mainnet)
99+
#[arg(long, default_value = "sepolia")]
100+
network: String,
101+
},
102+
103+
/// Deploy declared verifier contract
104+
#[command(about = "Deploy declared verifier contract")]
105+
Deploy {
106+
/// Class hash of the declared contract
107+
#[arg(long)]
108+
class_hash: Option<String>,
109+
},
110+
111+
/// Verify proof on-chain
112+
#[command(about = "Verify proof on Starknet using deployed verifier")]
113+
VerifyOnchain {
114+
/// Address of deployed verifier contract
115+
#[arg(short = 'a', long)]
116+
address: Option<String>,
117+
},
118+
}
119+
120+
#[derive(Subcommand)]
121+
pub enum EvmCommands {
122+
/// Generate Solidity verifier contract and Foundry project
123+
#[command(about = "Generate Solidity verifier contract with complete Foundry project setup")]
124+
Gen,
125+
126+
/// Generate Keccak oracle proof
127+
#[command(about = "Generate proof using bb with Keccak oracle hash")]
128+
Prove,
129+
130+
/// Verify Keccak oracle proof
131+
#[command(about = "Verify proof generated with Keccak oracle hash")]
132+
Verify,
133+
134+
/// Deploy verifier contract to EVM network
135+
#[command(about = "Deploy verifier contract using Foundry")]
136+
Deploy {
137+
/// Network to deploy to (mainnet or sepolia)
138+
#[arg(long, default_value = "sepolia")]
139+
network: String,
140+
},
141+
142+
/// Generate calldata for proof verification
143+
#[command(about = "Generate calldata for proof verification using cast")]
144+
Calldata,
145+
146+
/// Verify proof on-chain
147+
#[command(about = "Verify proof on EVM network using deployed verifier")]
148+
VerifyOnchain,
149+
}
150+
151+
#[derive(ValueEnum, Clone, Copy, Debug, PartialEq, Eq)]
152+
pub enum Backend {
153+
/// Barretenberg backend (EVM/Solidity)
154+
Bb,
155+
/// Starknet backend (Cairo)
156+
Starknet,
157+
/// All backends
158+
All,
159+
}

0 commit comments

Comments
 (0)