mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +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) {
|
||||
var algorithm string
|
||||
var iterations int
|
||||
|
@ -127,13 +134,10 @@ func hashPasswordCmd(cmdname string, args []string) {
|
|||
var saltlen int
|
||||
|
||||
cmd := flag.NewFlagSet(cmdname, flag.ExitOnError)
|
||||
cmd.Usage = func() {
|
||||
fmt.Fprintf(cmd.Output(),
|
||||
"%v [option...] %v password [option...] password...\n",
|
||||
setUsage(cmd, cmdname,
|
||||
"%v [option...] %v [option...] password...\n",
|
||||
os.Args[0], cmdname,
|
||||
)
|
||||
cmd.PrintDefaults()
|
||||
}
|
||||
cmd.StringVar(&algorithm, "hash", "pbkdf2",
|
||||
"hashing `algorithm`")
|
||||
cmd.IntVar(&iterations, "iterations", 4096,
|
||||
|
|
Loading…
Reference in a new issue