mirror of
https://github.com/jech/galene.git
synced 2024-11-12 19:55:59 +01:00
Factor out setUsage.
This commit is contained in:
parent
ece4929111
commit
e33029072b
1 changed files with 11 additions and 7 deletions
|
@ -119,6 +119,13 @@ func makePassword(pw string, algorithm string, iterations, length, saltlen, cost
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setUsage(cmd *flag.FlagSet, cmdname string, format string, args ...any) {
|
||||||
|
cmd.Usage = func() {
|
||||||
|
fmt.Fprintf(cmd.Output(), format, args...)
|
||||||
|
cmd.PrintDefaults()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func hashPasswordCmd(cmdname string, args []string) {
|
func hashPasswordCmd(cmdname string, args []string) {
|
||||||
var algorithm string
|
var algorithm string
|
||||||
var iterations int
|
var iterations int
|
||||||
|
@ -127,13 +134,10 @@ func hashPasswordCmd(cmdname string, args []string) {
|
||||||
var saltlen int
|
var saltlen int
|
||||||
|
|
||||||
cmd := flag.NewFlagSet(cmdname, flag.ExitOnError)
|
cmd := flag.NewFlagSet(cmdname, flag.ExitOnError)
|
||||||
cmd.Usage = func() {
|
setUsage(cmd, cmdname,
|
||||||
fmt.Fprintf(cmd.Output(),
|
"%v [option...] %v [option...] password...\n",
|
||||||
"%v [option...] %v password [option...] password...\n",
|
os.Args[0], cmdname,
|
||||||
os.Args[0], cmdname,
|
)
|
||||||
)
|
|
||||||
cmd.PrintDefaults()
|
|
||||||
}
|
|
||||||
cmd.StringVar(&algorithm, "hash", "pbkdf2",
|
cmd.StringVar(&algorithm, "hash", "pbkdf2",
|
||||||
"hashing `algorithm`")
|
"hashing `algorithm`")
|
||||||
cmd.IntVar(&iterations, "iterations", 4096,
|
cmd.IntVar(&iterations, "iterations", 4096,
|
||||||
|
|
Loading…
Reference in a new issue