Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nargo): print-acir command #1031

Merged
merged 1 commit into from
Mar 23, 2023
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
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 @@ -77,6 +79,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(())
}