update micro/cli to urfave/cli/v2 and fix go-micro

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-01-25 13:41:25 +03:00
parent 1d00f2f771
commit e6a34bcbe7
14 changed files with 183 additions and 176 deletions

View File

@@ -8,9 +8,9 @@ import (
"time"
"github.com/imdario/mergo"
"github.com/micro/cli"
"github.com/micro/go-micro/config/cmd"
"github.com/micro/go-micro/config/source"
"github.com/micro/cli/v2"
)
type cliSource struct {
@@ -21,11 +21,6 @@ type cliSource struct {
func (c *cliSource) Read() (*source.ChangeSet, error) {
var changes map[string]interface{}
for _, name := range c.ctx.GlobalFlagNames() {
tmp := toEntry(name, c.ctx.GlobalGeneric(name))
mergo.Map(&changes, tmp) // need to sort error handling
}
for _, name := range c.ctx.FlagNames() {
tmp := toEntry(name, c.ctx.Generic(name))
mergo.Map(&changes, tmp) // need to sort error handling

View File

@@ -5,9 +5,9 @@ import (
"os"
"testing"
"github.com/micro/cli"
"github.com/micro/go-micro/config/cmd"
"github.com/micro/go-micro/config/source"
"github.com/micro/cli/v2"
)
func test(t *testing.T, withContext bool) {
@@ -17,14 +17,15 @@ func test(t *testing.T, withContext bool) {
app := cmd.App()
app.Name = "testapp"
app.Flags = []cli.Flag{
cli.StringFlag{Name: "db-host"},
&cli.StringFlag{Name: "db-host"},
}
// with context
if withContext {
// set action
app.Action = func(c *cli.Context) {
app.Action = func(c *cli.Context) error {
src = WithContext(c)
return nil
}
// run app

View File

@@ -3,7 +3,7 @@ package cli
import (
"context"
"github.com/micro/cli"
"github.com/micro/cli/v2"
"github.com/micro/go-micro/config/source"
)

View File

@@ -5,7 +5,7 @@ import (
"flag"
"strings"
"github.com/micro/cli"
"github.com/micro/cli/v2"
)
func copyFlag(name string, ff *flag.Flag, set *flag.FlagSet) {
@@ -22,7 +22,7 @@ func normalizeFlags(flags []cli.Flag, set *flag.FlagSet) error {
visited[f.Name] = true
})
for _, f := range flags {
parts := strings.Split(f.GetName(), ",")
parts := f.Names()
if len(parts) == 1 {
continue
}