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) {
}
c.initFlags(x, m)
} 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)
} else if m[tagIgnore] != "" {
......
......@@ -2,12 +2,14 @@ module gitlab.schukai.com/oss/libraries/go/application/xflags
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 (
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // 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
)
// 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) {
assert.Equal(t, 0, len(s.errors))
assert.Equal(t, "test", s.command.name)
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