Skip to content

Commit 3d745b3

Browse files
committed
gnd: Fix duplicate "Next steps" hints during init+add loop
Add a quiet flag to AddOpt so that run_add skips printing "Next steps" when called from the add-more-contracts loop inside init. The message now prints exactly once, at the end of init_from_contract.
1 parent 20029a4 commit 3d745b3

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

gnd/src/commands/add.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ pub struct AddOpt {
4848
/// Block number to start indexing from
4949
#[clap(long)]
5050
pub start_block: Option<String>,
51+
52+
/// Suppress "Next steps" output (used when called from init loop)
53+
#[clap(skip)]
54+
pub quiet: bool,
5155
}
5256

5357
/// Run the add command.
@@ -142,10 +146,12 @@ pub async fn run_add(opt: AddOpt) -> Result<()> {
142146

143147
step(Step::Done, &format!("Added data source: {}", contract_name));
144148

145-
println!();
146-
println!("Next steps:");
147-
println!(" gnd codegen");
148-
println!(" gnd build");
149+
if !opt.quiet {
150+
println!();
151+
println!("Next steps:");
152+
println!(" gnd codegen");
153+
println!(" gnd build");
154+
}
149155

150156
Ok(())
151157
}
@@ -500,6 +506,7 @@ mod tests {
500506
merge_entities: false,
501507
network_file: PathBuf::from("networks.json"),
502508
start_block: None,
509+
quiet: false,
503510
};
504511

505512
let result = run_add(opt).await;
@@ -601,6 +608,7 @@ mod tests {
601608
merge_entities: false,
602609
network_file: PathBuf::from("networks.json"),
603610
start_block: None,
611+
quiet: false,
604612
};
605613

606614
let result = run_add(opt).await;

gnd/src/commands/init.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ async fn add_more_contracts_loop(directory: &Path, network: &str) -> Result<()>
435435
merge_entities: true, // Merge by default when adding during init
436436
network_file: PathBuf::from("networks.json"),
437437
start_block: start_block.map(|b| b.to_string()),
438+
quiet: true,
438439
};
439440

440441
if let Err(e) = run_add(add_opt).await {

0 commit comments

Comments
 (0)