Desertbit/grumble

From NovaOrdis Knowledge Base
Revision as of 18:56, 6 November 2024 by Ovidiu (talk | contribs) (Created page with "=External= * https://github.com/desertbit/grumble =Internal= * Go Open Source Packages =Overview= =Unit Testing Commands= ==Option 1== <syntaxhighlight lang='go'> command := somepackage.SomeCommand(...) app := grumble.New(&grumble.Config{Name: "test"}) app.AddCommand(command) args := []string{ "somecommand", "--arg1", "test1", "--arg2", "test2", } err := app.RunCommand(args) </syntaxhighlight> ==Option 2== <syntaxhighl...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

External

Internal

Overview

Unit Testing Commands

Option 1

command := somepackage.SomeCommand(...)
app := grumble.New(&grumble.Config{Name: "test"})
app.AddCommand(command)
args := []string{
    "somecommand",
    "--arg1", "test1",
    "--arg2", "test2",
}
err := app.RunCommand(args)

Option 2

flags := map[string]*grumble.FlagMapItem{
	"arg1":    flagValue(arg1),
	"arg2":    flagValue(arg2),
}
ctx := &grumble.Context{
	Flags:   flags,
	Context: context.Background(),
}
command := somepackage.SomeCommand(...)
err := command.Run(ctx)