From 80be7b909b99b26c25010a522240197e2c5be0b7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 18 Jul 2026 20:59:34 +0000 Subject: [PATCH] test(cli): bare 'amy' exits 2; key generate rejects unknown flags Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01CP4kfLCa3wWtE8Khy21Pkj --- cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/Main.kt | 2 +- .../com/vitorpamplona/amethyst/cli/commands/KeyCommands.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/Main.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/Main.kt index 1cb8cbca48..1974fa32cd 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/Main.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/Main.kt @@ -165,7 +165,7 @@ class AwaitTimeout( private val STRICT_ACCOUNT_VERBS = setOf("init", "create", "login", "logoff", "whoami") private suspend fun dispatch(argv: Array): Int { - if (argv.isEmpty() || argv[0] == "--help" || argv[0] == "-h") { + if (argv.firstOrNull() == "--help" || argv.firstOrNull() == "-h") { printUsage() return 0 } diff --git a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/KeyCommands.kt b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/KeyCommands.kt index ca55ba9395..8e118fb46c 100644 --- a/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/KeyCommands.kt +++ b/cli/src/main/kotlin/com/vitorpamplona/amethyst/cli/commands/KeyCommands.kt @@ -63,7 +63,7 @@ object KeyCommands { rest, "key ", mapOf( - "generate" to { _ -> generate() }, + "generate" to { tail -> generate(tail) }, "public" to { tail -> public(tail) }, "encrypt" to { tail -> encrypt(tail) }, "decrypt" to { tail -> decrypt(tail) }, @@ -134,7 +134,8 @@ object KeyCommands { return 0 } - private fun generate(): Int { + private fun generate(rest: Array): Int { + Args(rest).rejectUnknown() val id = Identity.create() Output.emit( mapOf(