Add blueprint file input as option for blueprint apply
This commit is contained in:
parent
a7741ec286
commit
8d8f91b76e
|
@ -565,6 +565,7 @@ where
|
|||
pub fn construct_parameter_incrementally<F>(
|
||||
&self,
|
||||
title: Option<&String>,
|
||||
blueprint_input: &Option<PathBuf>,
|
||||
ask: F,
|
||||
) -> Result<PlutusData, Error>
|
||||
where
|
||||
|
@ -574,7 +575,12 @@ where
|
|||
) -> Result<PlutusData, blueprint::error::Error>,
|
||||
{
|
||||
// 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)?;
|
||||
let blueprint: Blueprint = serde_json::from_reader(BufReader::new(blueprint))?;
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@ pub struct Args {
|
|||
/// `plutus.json`), or use the `cbor.serialise` function from the Aiken standard library.
|
||||
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.
|
||||
#[clap(short, long)]
|
||||
out: Option<PathBuf>,
|
||||
|
@ -42,6 +46,7 @@ pub struct Args {
|
|||
pub fn exec(
|
||||
Args {
|
||||
parameter,
|
||||
blueprint_input,
|
||||
out,
|
||||
module,
|
||||
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!(
|
||||
|
|
Loading…
Reference in New Issue