cobra-extension

command module
v0.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2022 License: MIT Imports: 2 Imported by: 4

README

Contributors GitHub release GitHub code size in bytes HitCount

This project aims to provide an easy way to let you writing a plugin for your CLI project. And it based on cobra.

Get started

go get github.com/linuxsuren/cobra-extension

Friendly to the flags test

You can add some tests for the flags quickly, for instance:

func TestFlagsValidation_Valid(t *testing.T) {
	boolFlag := true
	emptyFlag := true
	cmd := cobra.Command{}
	cmd.Flags().BoolVarP(&boolFlag, "test", "t", false, "usage test")
	cmd.Flags().BoolVarP(&emptyFlag, "empty", "", false, "")

	flags := FlagsValidation{{
		Name:      "test",
		Shorthand: "t",
	}, {
		Name:         "empty",
		UsageIsEmpty: true,
	}}
	flags.Valid(t, cmd.Flags())
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL