Files
Arve Knudsen 5070f7a75b Chore: Start harmonizing linting with plugin SDK (#25854)
* Chore: Harmonize linting with plugin SDK

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Chore: Fix linting issues

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-06-29 14:08:32 +02:00

27 lines
590 B
Go

package commandstest
import (
"flag"
"github.com/grafana/grafana/pkg/cmd/grafana-cli/utils"
"github.com/urfave/cli/v2"
)
// NewCliContext creates a new CLI context with a certain set of flags.
func NewCliContext(flags map[string]string) (*utils.ContextCommandLine, error) {
app := cli.App{
Name: "Test",
}
flagSet := flag.NewFlagSet("Test", 0)
for flag, value := range flags {
flagSet.String(flag, "", "")
if err := flagSet.Set(flag, value); err != nil {
return nil, err
}
}
return &utils.ContextCommandLine{
Context: cli.NewContext(&app, flagSet, nil),
}, nil
}