Skip to content

v0.8.0

Compare
Choose a tag to compare
@erikgeiser erikgeiser released this 13 Jan 20:01
· 7 commits to main since this release

As mentioned before, v0.8.0 introduces a breaking change by rewriting the selection prompt to use generics, but there are also a few other changes.

Changelog:

  • selection: The selection prompt now utilizes generics such that the choices don't have to be wrapped in Choice objects anymore and now the actual value of the the selected choice is returned. Migration instructions can be found below.
  • selection: A new option called LoopCursor was added. If enabled, the cursor now jumps to the top when pressing 'down' on the last entry and the other way around. See the custom selection prompt example for information on how to use it.
  • Fixed an issue where the wrong color profile was applied.
  • All dependencies were updated.

Migration:

  • When creating the selection prompt, instead of wrapping the choices like this
// before
selection.New("What do you pick?", selection.Choices([]string{"Horse", "Car", "Plane", "Bike"}))

they are now passed directly like this:

// now
selection.New("What do you pick?", []string{"Horse", "Car", "Plane", "Bike"})
  • The result is now directly returned, so instead of unwrapping the value from the choice object like this
// before
selected, err := sp.RunPrompt()
fmt.Println(selected.Value)

It can now be directly used instead:

// now
selected, err := sp.RunPrompt()
fmt.Println(selected)

  • selection.Model now can return both the selected choice in wrapped and unwrapped from with Model.Value() and Model.ValueAsChoice().
  • Some of the function properties of the selection prompt such as Filter or SelectedChoiceStyle now have a slightly different signature. Take a look at the custom selection example in which these properties are used.