Skip to content

Commit

Permalink
feat: default to outputting witness with file named after package (#6031
Browse files Browse the repository at this point in the history
)

# Description

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*

This PR updates `nargo execute` so that if no name is specified then the
witness is written to a file named after the noir package.

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
TomAFrench authored Sep 13, 2024
1 parent 5d2984f commit e74b4ae
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tooling/nargo_cli/src/cli/execute_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ use crate::errors::CliError;
#[clap(visible_alias = "e")]
pub(crate) struct ExecuteCommand {
/// Write the execution witness to named file
///
/// Defaults to the name of the package being executed.
witness_name: Option<String>,

/// The name of the toml file which contains the inputs for the prover
Expand Down Expand Up @@ -83,11 +85,11 @@ pub(crate) fn run(args: ExecuteCommand, config: NargoConfig) -> Result<(), CliEr
if let Some(return_value) = return_value {
println!("[{}] Circuit output: {return_value:?}", package.name);
}
if let Some(witness_name) = &args.witness_name {
let witness_path = save_witness_to_dir(witness_stack, witness_name, target_dir)?;

println!("[{}] Witness saved to {}", package.name, witness_path.display());
}
let package_name = package.name.clone().into();
let witness_name = args.witness_name.as_ref().unwrap_or(&package_name);
let witness_path = save_witness_to_dir(witness_stack, witness_name, target_dir)?;
println!("[{}] Witness saved to {}", package.name, witness_path.display());
}
Ok(())
}
Expand Down

0 comments on commit e74b4ae

Please sign in to comment.