Skip to content

Commit b532d2f

Browse files
committed
feat(client-cli): use unstable flag for tools command execution
1 parent c52b989 commit b532d2f

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

mithril-client-cli/src/main.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,16 @@ impl ArtifactCommands {
235235
Self::GenerateDoc(cmd) => cmd
236236
.execute(&mut Args::command())
237237
.map_err(|message| anyhow!(message)),
238-
Self::Tools(cmd) => cmd.execute().await,
238+
Self::Tools(cmd) => {
239+
if !context.is_unstable_enabled() {
240+
Err(anyhow!(Self::unstable_flag_missing_message(
241+
"tools",
242+
"utxo-hd snapshot-converter"
243+
)))
244+
} else {
245+
cmd.execute().await
246+
}
247+
}
239248
}
240249
}
241250

@@ -279,4 +288,32 @@ mod tests {
279288
.to_string()
280289
.contains("subcommand is only accepted using the --unstable flag."));
281290
}
291+
292+
#[tokio::test]
293+
async fn fail_if_tools_command_is_used_without_unstable_flag() {
294+
let args = Args::try_parse_from([
295+
"mithril-client",
296+
"tools",
297+
"utxo-hd",
298+
"snapshot-converter",
299+
"--db-directory",
300+
"whatever",
301+
"--cardano-network",
302+
"preview",
303+
"--cardano-node-version",
304+
"1.2.3",
305+
"--utxo-hd-flavor",
306+
"Legacy",
307+
])
308+
.unwrap();
309+
310+
let error = args
311+
.execute(Logger::root(slog::Discard, slog::o!()))
312+
.await
313+
.expect_err("Should fail if unstable flag missing");
314+
315+
assert!(error
316+
.to_string()
317+
.contains("subcommand is only accepted using the --unstable flag."));
318+
}
282319
}

0 commit comments

Comments
 (0)