go-getoptions v0.17.0 Release Notes
Release Date: 2019-10-24 // over 4 years ago-
๐ As the releases before, this release has 100% test coverage.
๐ This release keeps on the work of removing the kinks around subcommands.
An example showing subcommands can be found in ./examples/mygit.๐ฆ It also introduces the use of context to propagate cancelation signals, etc. to the child commands.
Finally, it introduces a new helper that captures interrupts (for example Ctrl-C) and returns a top level context.
๐ฅ Breaking changes
๐จ Refactor
NewCommmand
as a method.
This will allow the built-in help to have information about the parent.
It might also help with autocompletion.๐ Change sigature to
opt.NewCommand(name, description string)
.
It takes a name and description now.๐ Change signature of
CommandFn
to have acontext
as the first argument.
๐ฆ It will allow the parent to propagate cancelation signals, etc. to the child commands.
This change goes along a change to the helperopt.Dispatch
to also have acontext
as the first argument.โก๏ธ Updating:
- list := getoptions.NewCommand().Self("list", "list instances").+ list := opt.NewCommand("list", "list instances"). SetOption(parent.Option("help"), parent.Option("debug")). SetCommandFn(runInstanceList) list.StringSlice("tag", 1, 99, opt.Alias("t"), opt.Description("Any AWS tags you want to list"))- opt.Command(list) ...- err = opt.Dispatch("help", remaining)+ err = opt.Dispatch(context.Background(), "help", remaining) ...-func runInstanceList(opt \*getoptions.GetOpt, args []string) error {+func runInstanceList(ctx context.Context, opt \*getoptions.GetOpt, args []string) error {
๐ New Features
- ๐ฆ Introduce
opt.InterruptContext()
, a helper that returns a top level context that captures interrupt signals (os.Interrupt
,syscall.SIGHUP
,syscall.SIGTERM
).
An example can be found in ./examples/mygit.
- ๐ฆ Introduce