Lines
0 %
Functions
Branches
100 %
use clap::{command, ArgGroup, Args, Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(version)]
#[command(group(
// Ensures mutual exclusivity of config, or keypair and rpc_url
ArgGroup::new("config_group")
.required(false)
.args(&["config"])
.conflicts_with("rpc_url")
.conflicts_with("keypair")
.multiple(false)
))]
pub struct BonsolCli {
#[arg(
help = "The path to a Solana CLI config [Default: '~/.config/solana/cli/config.yml']",
short = 'c',
long
)]
pub config: Option<String>,
help = "The path to a Solana keypair file [Default: '~/.config/solana/id.json']",
short = 'k',
long,
requires = "rpc_url"
pub keypair: Option<String>,
help = "The Solana cluster the Solana CLI will make requests to",
short = 'u',
requires = "keypair"
pub rpc_url: Option<String>,
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Clone, Args)]
pub struct S3UploadArgs {
help = "Specify the S3 bucket name",
required = true,
value_parser = |s: &str| {
if s.trim().is_empty() {
anyhow::bail!("expected a non-empty string representation of an S3 bucket name")
Ok(s.to_string())
pub bucket: String,
help = "Specify the AWS access key ID",
env = "AWS_ACCESS_KEY_ID"
pub access_key: String,
help = "Specify the AWS secret access key",
env = "AWS_SECRET_ACCESS_KEY"
pub secret_key: String,
help = "Specify the AWS region",
env = "AWS_REGION"
pub region: String,
help = "Specify the AWS S3 compatibility endpoint",
required = false,
env = "AWS_S3_ENDPOINT"
pub endpoint: Option<String>,
#[command(flatten)]
pub shared_args: SharedDeployArgs,
pub struct UrlUploadArgs {
#[arg(help = "Specify a URL endpoint to deploy to", long, required = true)]
pub url: String,
#[derive(Debug, Clone, Subcommand)]
pub enum DeployArgs {
#[command(about = "Deploy a program using an AWS S3 bucket")]
S3(S3UploadArgs),
#[command(about = "Deploy a program manually with a URL")]
Url(UrlUploadArgs),
impl DeployArgs {
pub fn shared_args(&self) -> SharedDeployArgs {
match self {
Self::S3(s3) => s3.shared_args.clone(),
Self::Url(url) => url.shared_args.clone(),
pub struct SharedDeployArgs {
help = "The path to the program's manifest file (manifest.json)",
short = 'm',
pub manifest_path: String,
help = "Whether to automatically confirm deployment",
short = 'y',
pub auto_confirm: bool,
#[derive(Subcommand, Debug)]
pub enum Command {
#[command(
about = "Deploy a program with various storage options, such as S3, or manually with a URL"
Deploy {
#[clap(subcommand)]
deploy_args: DeployArgs,
},
#[command(about = "Build a ZK program")]
Build {
help = "The path to a ZK program folder containing a Cargo.toml",
short = 'z',
zk_program_path: String,
#[command(about = "Estimate the execution cost of a ZK RISC0 program")]
Estimate {
manifest_path: String,
#[arg(help = "The path to the program input file", short = 'i', long)]
input_file: Option<String>,
help = "Set the maximum number of cycles [default: 16777216u64]",
max_cycles: Option<u64>,
Execute {
#[arg(short = 'f', long)]
execution_request_file: Option<String>,
// overridable settings
#[arg(short = 'p', long)]
program_id: Option<String>,
#[arg(short = 'e', long)]
execution_id: Option<String>,
#[arg(short = 'x', long)]
expiry: Option<u64>,
#[arg(short = 'm', long)]
tip: Option<u64>,
#[arg(short = 'i', long, help = "override inputs in execution request file")]
/// wait for execution to be proven
#[arg(short = 'w', long, help = "wait for execution to be proven")]
wait: bool,
/// timeout in seconds
#[arg(short = 't', long, help = "timeout in seconds")]
timeout: Option<u64>,
Prove {
manifest_path: Option<String>,
#[arg(short = 'i')]
execution_id: String,
#[arg(short = 'o')]
output_location: Option<String>,
#[command(about = "Initialize a new project")]
Init {
#[arg(short = 'd', long)]
dir: Option<String>,
#[arg(short = 'n', long)]
project_name: String,