Check arguments before looking for the mnemonic (closes #79)
check / check (push) Canceled after 0s

The key index, --words, the --to recipients and the input file of
age encrypt and age decrypt were checked only after the mnemonic had
been obtained, so a run that could not succeed still prompted for it or
ran the mnemonic command. options.Index now refuses an index above
derive.MaxIndex, which covers every command group; the mnemonic command
calls the new childmnemonic.CheckWords first; age encrypt reads its
recipients with the new agekey.Recipients, and both age commands open
their input, before the key is derived. The README says which checks
come first.

Judgement call: the -o path is still looked at after the mnemonic.

Model: opus-5-5
This commit was merged in pull request #84.
This commit is contained in:
2026-10-14 21:05:48 +02:00
parent b02f502928
commit d1ed234bc9
9 changed files with 162 additions and 62 deletions
+5 -8
View File
@@ -119,12 +119,12 @@ func TestAnExtraRecipientCanReadItTooAndSoCanTheDerivedOne(t *testing.T) {
mine, theirs := forIndex(t, 0), forIndex(t, 1)
to, err := agekey.Recipients([]string{theirs.Recipient()})
require.NoError(t, err)
var sealed bytes.Buffer
err := mine.Encrypt(
&sealed, strings.NewReader("hello"),
[]string{theirs.Recipient()}, false,
)
err = mine.Encrypt(&sealed, strings.NewReader("hello"), to, false)
require.NoError(t, err)
for _, key := range []*agekey.Key{mine, theirs} {
@@ -138,10 +138,7 @@ func TestAnExtraRecipientCanReadItTooAndSoCanTheDerivedOne(t *testing.T) {
func TestARecipientThatIsNotOneIsRefused(t *testing.T) {
t.Parallel()
err := forIndex(t, 0).Encrypt(
&bytes.Buffer{}, strings.NewReader("hello"),
[]string{"not a recipient"}, false,
)
_, err := agekey.Recipients([]string{"not a recipient"})
require.Error(t, err)
}