cargo_risczero/
lib.rs

1// Copyright 2025 RISC Zero, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#![doc = include_str!("../README.md")]
16#![deny(missing_docs)]
17#![deny(rustdoc::broken_intra_doc_links)]
18#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
19
20mod commands;
21mod utils;
22
23use clap::{Args, Parser, Subcommand};
24
25use self::commands::{
26    bake::BakeCommand, build::BuildCommand, build_toolchain::BuildToolchainCommand,
27    install::InstallCommand, new::NewCommand, verify::VerifyCommand,
28};
29
30#[derive(Parser)]
31#[command(name = "cargo", bin_name = "cargo")]
32/// Main cargo command
33pub enum CargoCli {
34    /// The `risczero` command
35    Risczero(RisczeroArgs),
36}
37
38#[derive(Args)]
39#[command(author, version, about, long_about = None)]
40#[non_exhaustive]
41/// `cargo risczero`
42pub struct RisczeroArgs {
43    #[command(subcommand)]
44    /// Which `risczero` command to run
45    pub command: Commands,
46}
47
48#[derive(Subcommand)]
49#[non_exhaustive]
50/// Primary commands  of `cargo risczero`.
51pub enum Commands {
52    /// Bake guest code.
53    Bake(BakeCommand),
54
55    /// Build guest code.
56    Build(BuildCommand),
57
58    /// Build the riscv32im-risc0-zkvm-elf toolchain.
59    BuildToolchain(BuildToolchainCommand),
60
61    /// Guest commands
62    #[cfg(feature = "experimental")]
63    Guest(commands::guest::GuestCommand),
64
65    /// Install the riscv32im-risc0-zkvm-elf toolchain.
66    Install(InstallCommand),
67
68    /// Creates a new risczero starter project.
69    New(NewCommand),
70
71    /// Verifies if a receipt is valid.
72    Verify(VerifyCommand),
73}
74
75#[cfg(test)]
76mod tests {
77    use clap::CommandFactory;
78
79    use super::*;
80
81    #[test]
82    fn verify_app() {
83        CargoCli::command().debug_assert();
84    }
85}