Categorygithub.com/linuxsuren/cobra-extension
modulepackage
0.0.16
Repository: https://github.com/linuxsuren/cobra-extension.git
Documentation: pkg.go.dev

# 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())
}

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author