Read --index and --words as decimal numbers (closes #75)
check / check (push) Successful in 3m14s
check / check (push) Successful in 3m14s
Both flags were uint32 flags, which the flag library reads with Go's base-0 rules, so `-n 010` derived key 8 and `0x10` or `1_0` were accepted. They are now string flags read by options.Decimal, which takes decimal digits only: a leading zero stays decimal, and a base prefix, an underscore or a sign is refused with an error naming the flag, before the mnemonic is looked for. --help shows both as a number, and the README says the index is a decimal number. Model: opus-5-5
This commit is contained in:
@@ -3,6 +3,7 @@ package mnemonic
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sneak.berlin/go/keyfunc/internal/childmnemonic"
|
||||
@@ -31,9 +32,9 @@ func Command() *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().Uint32(
|
||||
"words", childmnemonic.DefaultWords,
|
||||
"how long the child mnemonic is: 12, 18 or 24 words",
|
||||
cmd.Flags().String(
|
||||
"words", strconv.Itoa(childmnemonic.DefaultWords),
|
||||
"the `number` of words in the child mnemonic: 12, 18 or 24",
|
||||
)
|
||||
|
||||
return cmd
|
||||
@@ -46,9 +47,9 @@ func derived(cmd *cobra.Command) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
words, err := cmd.Flags().GetUint32("words")
|
||||
words, err := options.Decimal(cmd, "words")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("reading the word count: %w", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
parent, err := options.Mnemonic(cmd)
|
||||
|
||||
Reference in New Issue
Block a user