Skip to content

Commit

Permalink
Add command suggestion when there are no stacklets
Browse files Browse the repository at this point in the history
  • Loading branch information
Techassi committed Oct 17, 2023
1 parent 5b1afc7 commit e45cb0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion rust/stackablectl/src/cmds/stacklet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,21 @@ async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result<String, CmdError
.context(StackletListSnafu)?;

if stacklets.is_empty() {
return Ok("No stacklets".into());
let mut result = cli.result();

result
.with_command_hint(
"stackablectl stack install <STACK_NAME>",
"install a complete stack",
)
.with_command_hint(
"stackablectl demo install <DEMO_NAME>",
"install an end-to-end demo",
)
.with_output("No stacklets found");

// TODO (Techassi): Remove unwrap
return Ok(result.render().unwrap());
}

match args.output_type {
Expand Down
4 changes: 2 additions & 2 deletions rust/stackablectl/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ where
"{}",
color_print::cformat!("An unrecoverable error occured: <s><r>{}</></>\n\n", self)
)?;
write!(
writeln!(
report,
"Caused by these errors (recent errors listed first):\n"
"Caused by these errors (recent errors listed first):"
)?;

let mut error: &dyn std::error::Error = &self;
Expand Down

0 comments on commit e45cb0c

Please sign in to comment.