![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
github.com/godoes/wmenu/v5
Package wmenu creates menus for cli programs. It uses wlog for its interface with the command line. It uses os.Stdin, os.Stdout, and os.Stderr with concurrency by default. wmenu allows you to change the color of the different parts of the menu. This package also creates its own error structure, so you can type assert if you need to. wmenu will validate all responses before calling any function. It will also figure out which function should be called, so you don't have to.
import "github.com/godoes/wmenu/v5"
I try and keep up with my tags. To use the version and stable it is recommended to use govendor
or another vendoring tool that allows you to build your project for specific tags.
govendor fetch github.com/godoes/wmenu@v4
The above will grab the latest v4 at that time and mark it. It will then be stable for you to use.
I will try to support as many versions as possible but please be patient.
https://pkg.go.dev/github.com/godoes/wmenu/v5
import "github.com/godoes/wmenu/v5"
This is a simple use of the package. (NOTE: THIS IS A V4 SAMPLE)
menu := wmenu.NewMenu("What is your favorite food?")
menu.Action(func (opts []wmenu.Opt) error {fmt.Printf(opts[0].Text + " is your favorite food."); return nil})
menu.Option("Pizza", nil, true, nil)
menu.Option("Ice Cream", nil, false, nil)
menu.Option("Tacos", nil, false, func(opt wmenu.Opt) error {
fmt.Printf("Tacos are great")
return nil
})
err := menu.Run()
if err != nil{
log.Fatal(err)
}
The output would look like this:
1) *Pizza
2) Ice Cream
3) Tacos
What is your favorite food?
If the user just presses [Enter]
then the option(s) with the *
will be selected. This indicates that it is a default function. If they choose 1
then they would see Ice Cream is your favorite food.
. This used the Action's function because the option selected didn't have a function along with it. But if they choose 2
they would see Tacos are great
. That option did have a function with it which take precedence over Action.
You can you also use:
menu.AllowMultiple()
This will allow the user to select multiple options. The default delimiter is a [space]
, but can be changed by using:
menu.SetSeperator("some string")
Another feature is the ability to ask yes or no questions.
menu.IsYesNo(0)
This will remove any options previously added options and hide the ones used for the menu. It will simply just ask yes or no. Menu will parse and validate the response for you. This option will always call the Action's function and pass in the option that was selected.
Allows the user to pass anything for the value, so it can be retrieved later in the function. The following is to showcase the power of this.
The following was written in V3 but the concept holds for V4. V4 just changed
actFunc
to befunc([]wmenu.Opt) error
instead.
type NameEntity struct {
FirstName string
LastName string
}
optFunc := func(opt wmenu.Opt) error {
fmt.Println("Option 1 was chosen.")
return nil
}
actFunc := func(opt wmenu.Opt) error {
name, ok := opt.Value.(NameEntity)
if !ok {
log.Fatal("Could not cast option's value to NameEntity")
}
fmt.Printf("%s has an id of %d.\n", opt.Text, opt.ID)
fmt.Printf("Hello, %s %s.\n", name.FirstName, name.LastName)
return nil
}
menu := NewMenu("Choose an option.")
menu.ChangeReaderWriter(reader, os.Stdout, os.Stderr)
menu.Action(actFunc)
menu.Option("Option 1", NameEntity{"Bill", "Bob"}, true, optFunc)
menu.Option("Option 2", NameEntity{"John", "Doe"}, false, nil)
menu.Option("Option 3", NameEntity{"Jane", "Doe"}, false, nil)
err := menu.Run()
if err != nil {
log.Fatal(err)
}
The immediate output would be:
Output:
1) *Option 1
2) Option 2
3) Option 3
Choose an option.
Now if the user pushes [ENTER]
the output would be Options 0 was chosen.
. But now if either option 1 or 2 were chosen it would cast the options value to a NameEntity allowing the function to be able to gather both the first name and last name of the NameEntity. If you want though you can just pass in nil
as the value or even a string ("hello"
) since both of these implement the empty interface required by value. Just make sure to cast the values, so you can use them appropriately.
This whole package has been documented and has a few examples in:
You should read the docs to find all functions and structures at your fingertips.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.