Skip to content

Commit

Permalink
feat(nargo): print-acir command (#1031)
Browse files Browse the repository at this point in the history
feat(nargo) print-acir command
  • Loading branch information
joss-aztec authored Mar 23, 2023
1 parent 2e38ab0 commit 408d9c0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/nargo/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod execute_cmd;
mod gates_cmd;
mod new_cmd;
mod preprocess_cmd;
mod print_acir_cmd;
mod prove_cmd;
mod test_cmd;
mod verify_cmd;
Expand Down Expand Up @@ -58,6 +59,7 @@ enum NargoCommand {
Preprocess(preprocess_cmd::PreprocessCommand),
Test(test_cmd::TestCommand),
Gates(gates_cmd::GatesCommand),
PrintAcir(print_acir_cmd::PrintAcirCommand),
}

pub fn start_cli() -> eyre::Result<()> {
Expand All @@ -79,6 +81,7 @@ pub fn start_cli() -> eyre::Result<()> {
NargoCommand::Test(args) => test_cmd::run(args, config),
NargoCommand::Gates(args) => gates_cmd::run(args, config),
NargoCommand::CodegenVerifier(args) => codegen_verifier_cmd::run(args, config),
NargoCommand::PrintAcir(args) => print_acir_cmd::run(args, config),
}?;

Ok(())
Expand Down
29 changes: 29 additions & 0 deletions crates/nargo/src/cli/print_acir_cmd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use clap::Args;
use noirc_driver::CompileOptions;
use std::path::Path;

use crate::cli::compile_cmd::compile_circuit;
use crate::errors::CliError;

use super::NargoConfig;

/// Prints out the ACIR for a compiled circuit
#[derive(Debug, Clone, Args)]
pub(crate) struct PrintAcirCommand {
#[clap(flatten)]
compile_options: CompileOptions,
}

pub(crate) fn run(args: PrintAcirCommand, config: NargoConfig) -> Result<(), CliError> {
print_acir_with_path(config.program_dir, &args.compile_options)
}

fn print_acir_with_path<P: AsRef<Path>>(
program_dir: P,
compile_options: &CompileOptions,
) -> Result<(), CliError> {
let compiled_program = compile_circuit(program_dir.as_ref(), compile_options)?;
println!("{}", compiled_program.circuit);

Ok(())
}

0 comments on commit 408d9c0

Please sign in to comment.