Closed XiaoliChan closed 6 months ago
@XiaoliChan it will take default value into action when we mention flag and doesn't provide any value. ex:
✗ ./basic
Got Severity: [high]
Dynamic Values Output
title size: 0
target:
hashes: []
➜ basic git:(main) ✗ ./basic -title
Got Severity: [high]
Dynamic Values Output
title size: 50
target:
hashes: []
@RamanaReddy0M Thanks for your reply.
I see, but it looks like weird
┌──(xiaoli㉿kali)-[/tmp/goflags/examples/basic]
└─$ ./main
Got Severity: [high]
Dynamic Values Output
title size: 0
target:
hashes: []
┌──(xiaoli㉿kali)-[/tmp/goflags/examples/basic]
└─$ ./main -title
Got Severity: [high]
Dynamic Values Output
title size: 50
target:
hashes: []
In the user's eyes, it should look like other flags, provide a default value to the variable.
The second thing is even I provide value to the flag, it looks like a bool
type variable.
┌──(xiaoli㉿kali)-[/tmp/goflags/examples/basic]
└─$ ./main -title 10
Got Severity: [high]
Dynamic Values Output
title size: 50
target:
hashes: []
Seems a bit counterintuitive
@XiaoliChan
$ ./main -title=10
This is how you are supposed to pass the value for the flags created by DynamicVar.
The DynamicVar serves the purpose of flag without value(takes default value) or with value which is missing in go standard library and flag=xxx
is the limitation we had here.
If this is not the case you can use regular IntVar for the consistency.
@RamanaReddy0M Thanks for providing more details about DynamicVar
The reason why I asking this, because I want to use float
type value, but looks like it's not support
var tmp float64
flagSet.CreateGroup("Dynmaic", "Dynamic",
flagSet.DynamicVar(&tmp, "tmp", 38.0, "temperature"),
)
it support float as well.
Oh, I also need to set it as default XD
@XiaoliChan seems resolved closing the issue.
DynamicVar
&DynamicVarP
is not workingENV:
Code: https://github.com/projectdiscovery/goflags/blob/main/examples/basic/main.go
Issues details:
0
even if it set default value to50
inint
type data (string will get blank value)