Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xflags
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Go
Application
xflags
Commits
a680bb80
Verified
Commit
a680bb80
authored
2 years ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: handle values from type flags.Bool
parent
2728224f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
help_test.go
+3
-3
3 additions, 3 deletions
help_test.go
mapping.go
+1
-1
1 addition, 1 deletion
mapping.go
type.go
+5
-2
5 additions, 2 deletions
type.go
with
9 additions
and
6 deletions
help_test.go
+
3
−
3
View file @
a680bb80
...
...
@@ -32,9 +32,9 @@ func TestGetHelp(t *testing.T) {
args
[]
string
substring
string
}{
{
"test1"
,
[]
string
{
"sub1"
,
"--help"
},
"Usage:
test1 sub1
[global options] [command] [arguments]"
},
{
"test1"
,
[]
string
{
"xsd"
,
"help"
},
"Usage:
test1
[global options] [command] [arguments]"
},
{
"test2"
,
[]
string
{
"sub1"
,
"sub2"
},
"Usage:
test2 sub1 sub2
[global options] [command] [arguments]"
},
{
"test1"
,
[]
string
{
"sub1"
,
"--help"
},
"Usage: [global options] [command] [arguments]
\n\n
Global Options:
\n
-a
\t
Message A
\n
-x int
\n
\t
Message X
\n\n
Command: sub1
\n\n
Options:
\n
-b
\t
Message B
\n
"
},
{
"test1"
,
[]
string
{
"xsd"
,
"help"
},
"Usage: [global options] [command] [arguments]
\n\n
Global Options:
\n
-a
\t
Message A
\n
-x int
\n
\t
Message X
\n\n
Command: sub1
\n\n
Options:
\n
-b
\t
Message B
\n
"
},
{
"test2"
,
[]
string
{
"sub1"
,
"sub2"
},
"Usage: [global options] [command] [arguments]
\n\n
Global Options:
\n
-a
\t
Message A
\n
-x int
\n
\t
Message X
\n\n
Command: sub1
\n\n
Options:
\n
-b
\t
Message B
\n
"
},
}
for
_
,
table
:=
range
tables
{
...
...
This diff is collapsed.
Click to expand it.
mapping.go
+
1
−
1
View file @
a680bb80
...
...
@@ -37,7 +37,7 @@ func (s *Settings[C]) assignValues(c cmd[C]) {
flgs
.
Visit
(
func
(
f
*
flag
.
Flag
)
{
name
:=
f
.
Name
value
:=
f
.
Value
//
.String()
value
:=
f
.
Value
.
String
()
k
,
ok
:=
c
.
tagMapping
[
name
]
if
!
ok
{
...
...
This diff is collapsed.
Click to expand it.
type.go
+
5
−
2
View file @
a680bb80
package
xflags
import
"strings"
import
(
"fmt"
"strings"
)
type
StringFlags
[]
string
...
...
@@ -18,7 +21,7 @@ type IntFlags []int
func
(
i
*
IntFlags
)
String
()
string
{
r
:=
make
([]
string
,
len
(
*
i
))
for
k
,
v
:=
range
*
i
{
r
[
k
]
=
string
(
v
)
r
[
k
]
=
fmt
.
Sprintf
(
"%c"
,
v
)
}
return
strings
.
Join
(
r
,
","
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment