Skip to content
Snippets Groups Projects
Verified Commit 3ae774c1 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix remove tag for command #4

parent 54753352
No related branches found
No related tags found
No related merge requests found
...@@ -163,7 +163,7 @@ func (c *cmd[C]) parseStruct(dta any) { ...@@ -163,7 +163,7 @@ func (c *cmd[C]) parseStruct(dta any) {
} }
c.initFlags(x, m) c.initFlags(x, m)
} else if m[tagCommand] != "" { } else if m[tagCommand] != "" {
c.tagMapping[m[tagCommand]] = v.Type().Field(i).Name //c.tagMapping["cmd"+m[tagCommand]] = v.Type().Field(i).Name
c.initCommands(x, m, v.Type().Field(i).Name) c.initCommands(x, m, v.Type().Field(i).Name)
} else if m[tagIgnore] != "" { } else if m[tagIgnore] != "" {
......
...@@ -2,12 +2,14 @@ module gitlab.schukai.com/oss/libraries/go/application/xflags ...@@ -2,12 +2,14 @@ module gitlab.schukai.com/oss/libraries/go/application/xflags
go 1.19 go 1.19
require github.com/stretchr/testify v1.8.0 require (
github.com/stretchr/testify v1.8.0
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.1
)
require ( require (
github.com/agnivade/levenshtein v1.1.1 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
...@@ -14,6 +14,8 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK ...@@ -14,6 +14,8 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.0 h1:mSxk2q/npskmHMmw1oF4moccjGav5dL6qmff2njUV7A= gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.0 h1:mSxk2q/npskmHMmw1oF4moccjGav5dL6qmff2njUV7A=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.0/go.mod h1:UvdD4NAf3gLKYafabJD7e9ZCOetzM9JZ9y4GkZukPVU= gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.0/go.mod h1:UvdD4NAf3gLKYafabJD7e9ZCOetzM9JZ9y4GkZukPVU=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.1 h1:oyElaqEiyr2XgaE1CYwD8LoeHsuR/vQD/p6k3jYbJFs=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.3.1/go.mod h1:UvdD4NAf3gLKYafabJD7e9ZCOetzM9JZ9y4GkZukPVU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
......
// Copyright 2022 schukai GmbH
// SPDX-License-Identifier: AGPL-3.0
package xflags
import (
"github.com/stretchr/testify/assert"
"testing"
)
type testConfigCommandIssue4 struct {
}
type testCmdStructIssue4 struct {
ConfigPath string `long:"config" short:"c" description:"Path to configuration file"`
Config testConfigCommandIssue4 `command:"config" description:"Config commands"`
}
// TestIssue4 tests the issue #4.
func TestIssue4B(t *testing.T) {
s := New("test", testCmdStructIssue4{})
s.Parse([]string{"--config", "config"})
assert.Equal(t, s.HasErrors(), false)
if s.HasErrors() {
t.Log(s.Errors())
}
}
...@@ -24,5 +24,5 @@ func TestInitCommands(t *testing.T) { ...@@ -24,5 +24,5 @@ func TestInitCommands(t *testing.T) {
assert.Equal(t, 0, len(s.errors)) assert.Equal(t, 0, len(s.errors))
assert.Equal(t, "test", s.command.name) assert.Equal(t, "test", s.command.name)
assert.Equal(t, 1, len(s.command.commands)) assert.Equal(t, 1, len(s.command.commands))
assert.Equal(t, 3, len(s.command.tagMapping)) assert.Equal(t, 2, len(s.command.tagMapping))
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment