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
2728224f
Verified
Commit
2728224f
authored
2 years ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
feat: hint and error functions
parent
2b16160e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
error.go
+5
-8
5 additions, 8 deletions
error.go
help-util.go
+1
-1
1 addition, 1 deletion
help-util.go
hint.go
+14
-0
14 additions, 0 deletions
hint.go
mapping.go
+1
-1
1 addition, 1 deletion
mapping.go
with
21 additions
and
10 deletions
error.go
+
5
−
8
View file @
2728224f
...
...
@@ -20,19 +20,16 @@ func (s *Settings[C]) HasErrors() bool {
return
len
(
s
.
errors
)
>
0
}
func
(
s
*
Settings
[
C
])
HasHint
()
bool
{
return
s
.
hint
!=
""
}
func
(
s
*
Settings
[
C
])
GetHint
()
string
{
return
s
.
hint
}
// Get all errors
func
(
s
*
Settings
[
C
])
Errors
()
[]
error
{
return
s
.
errors
}
func
(
s
*
Settings
[
C
])
AddError
(
err
error
)
*
Settings
[
C
]
{
s
.
errors
=
append
(
s
.
errors
,
err
)
return
s
}
var
WatchListNotInitializedError
=
errors
.
New
(
"watch list not initialized"
)
var
MissingCommandError
=
errors
.
New
(
"missing command"
)
var
NotParsedError
=
errors
.
New
(
"flag set not parsed"
)
...
...
This diff is collapsed.
Click to expand it.
help-util.go
+
1
−
1
View file @
2728224f
...
...
@@ -96,7 +96,7 @@ func getFlagTable(f *flag.FlagSet) []string {
// isZeroValue determines whether the string represents the zero
// value for a flag.
func
isZeroValue
(
f
*
flag
.
Flag
,
value
string
)
(
ok
bool
,
err
error
)
{
//
Build
a zero value of the flag's Value type, and see if the
//
Sync
a zero value of the flag's Value type, and see if the
// result of calling its String method equals the value passed in.
// This works unless the Value type is itself an interface type.
typ
:=
reflect
.
TypeOf
(
f
.
Value
)
...
...
This diff is collapsed.
Click to expand it.
hint.go
+
14
−
0
View file @
2728224f
package
xflags
func
(
s
*
Settings
[
C
])
SetHint
(
hint
string
)
*
Settings
[
C
]
{
s
.
hint
=
hint
return
s
}
func
(
s
*
Settings
[
C
])
HasHint
()
bool
{
return
s
.
hint
!=
""
}
func
(
s
*
Settings
[
C
])
GetHint
()
string
{
return
s
.
hint
}
This diff is collapsed.
Click to expand it.
mapping.go
+
1
−
1
View file @
2728224f
...
...
@@ -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.
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