Skip to content

Commit

Permalink
[ux] Do not show create type chooser if only one exists (#2752)
Browse files Browse the repository at this point in the history
This change skips the first dialog in the create wizard
in case there is only one type of template.

Signed-off-by: Dominik Schulz <[email protected]>
  • Loading branch information
dominikschulz authored Dec 28, 2023
1 parent b2b61b2 commit ff70638
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/action/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,19 @@ func (s *Action) Create(c *cli.Context) error {

wiz, err := create.New(ctx, s.Store.Storage(ctx, c.String("store")))
if err != nil {
return err
return exit.Error(exit.Unknown, err, "Failed to initialize wizard")
}

acts := wiz.Actions(s.Store, s.createPrintOrCopy)
// this should usually not happen because we initialize the templates if none
// exist.
if len(acts) < 1 {
return exit.Error(exit.Unknown, nil, "no wizard actions available")
}
// no need to ask if there is only one action available.
if len(acts) == 1 {
return acts.Run(ctx, c, 0)
}

act, sel := cui.GetSelection(ctx, "Please select the type of secret you would like to create", acts.Selection())
switch act {
Expand Down

0 comments on commit ff70638

Please sign in to comment.