github charmbracelet/huh v0.4.2

one month ago

Your favourite files 📁

Huh? v0.4.0 (v0.4.2) introduces the File Picker to forms ✨

Prompt users to select a file in just a few lines of code, you know the drill :)

var file string

huh.NewFilePicker().
    Title("Select a file:").
    Description("This will be your profile image.").
    AllowedTypes([]string{".png", ".jpeg", ".webp", ".gif"}).
    Value(&file)

Made with VHS


Field Interface

Zoom

File pickers introduce a new Zoom method to the Field interface.

type Field interface {

    // ...

    Zoom() bool

    // ...

}

Zoom tells the form whether this field should be the only visible field.

Notice how the FilePicker field zooms in when selecting a file and zooms out when the file is selected, showing only the selected file.

Skip

Notes introduce a new Skip method to the Field interface.

type Field interface {

    // ...

    Skip() bool

    // ...

}

Skip indicates to the form whether or not to skip this field, i.e. don't let the user interact with it. This is useful for notes to be purely informational.

What else?

Bug Fixes

New Contributors

A special thanks to everyone who made this release of Huh? possible! 🤗

Full Changelog: v0.3.0...v0.4.0


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Slack.

Don't miss a new huh release

NewReleases is sending notifications on new releases.