Add blueprint file input as option for blueprint apply

This commit is contained in:
Riley-Kilgore 2024-10-24 09:24:04 -07:00 committed by Lucas
parent a7741ec286
commit 8d8f91b76e
2 changed files with 13 additions and 2 deletions

View File

@ -565,6 +565,7 @@ where
pub fn construct_parameter_incrementally<F>( pub fn construct_parameter_incrementally<F>(
&self, &self,
title: Option<&String>, title: Option<&String>,
blueprint_input: &Option<PathBuf>,
ask: F, ask: F,
) -> Result<PlutusData, Error> ) -> Result<PlutusData, Error>
where where
@ -574,7 +575,12 @@ where
) -> Result<PlutusData, blueprint::error::Error>, ) -> Result<PlutusData, blueprint::error::Error>,
{ {
// Read blueprint // Read blueprint
let blueprint = File::open(self.blueprint_path()) let project_blueprint_path = self.blueprint_path();
let blueprint_path = blueprint_input
.as_ref()
.map(|p| p.as_path())
.unwrap_or_else(|| &project_blueprint_path);
let blueprint = File::open(blueprint_path)
.map_err(|_| blueprint::error::Error::InvalidOrMissingFile)?; .map_err(|_| blueprint::error::Error::InvalidOrMissingFile)?;
let blueprint: Blueprint = serde_json::from_reader(BufReader::new(blueprint))?; let blueprint: Blueprint = serde_json::from_reader(BufReader::new(blueprint))?;

View File

@ -26,6 +26,10 @@ pub struct Args {
/// `plutus.json`), or use the `cbor.serialise` function from the Aiken standard library. /// `plutus.json`), or use the `cbor.serialise` function from the Aiken standard library.
parameter: Option<String>, parameter: Option<String>,
/// Path to a blueprint file to be used as input.
#[clap(short = 'b', long, value_parser)]
blueprint_input: Option<PathBuf>,
/// Output file. Optional, print on stdout when omitted. /// Output file. Optional, print on stdout when omitted.
#[clap(short, long)] #[clap(short, long)]
out: Option<PathBuf>, out: Option<PathBuf>,
@ -42,6 +46,7 @@ pub struct Args {
pub fn exec( pub fn exec(
Args { Args {
parameter, parameter,
blueprint_input,
out, out,
module, module,
validator, validator,
@ -103,7 +108,7 @@ pub fn exec(
}) })
} }
None => p.construct_parameter_incrementally(title, ask_schema)?, None => p.construct_parameter_incrementally(title, &blueprint_input, ask_schema)?,
}; };
eprintln!( eprintln!(