# HG changeset patch # User David Barts # Date 1720199491 25200 # Node ID 69526ae8c8de92ab36b5b6c9ae89fe52682c379c # Parent 131e39d96862115c90347cada2ef5ae74b8b2831 Allow list --name to be abbreviated -n, since it is so commonly used. diff -r 131e39d96862 -r 69526ae8c8de src/main/kotlin/name/blackcap/passman/ListSubcommand.kt --- a/src/main/kotlin/name/blackcap/passman/ListSubcommand.kt Thu Jul 04 09:49:36 2024 -0700 +++ b/src/main/kotlin/name/blackcap/passman/ListSubcommand.kt Fri Jul 05 10:11:31 2024 -0700 @@ -21,8 +21,10 @@ OptionDescriptor(HELP, "Print this help message."), OptionDescriptor(LONG, "Long format listing.") ) + val ABBREV_STRING_OPTIONS = listOf( + OptionDescriptor(NAME, "Match site name.") + ) val STRING_OPTIONS = listOf( - OptionDescriptor(NAME, "Match site name."), OptionDescriptor(NOTES, "Match notes."), OptionDescriptor(USERNAME, "Match username.") ) @@ -48,6 +50,10 @@ FLAG_OPTIONS.forEach { addOption(it.name.first().toString(), it.name, false, it.help) } + ABBREV_STRING_OPTIONS.forEach() { + addOption(Option(it.name.first().toString(), it.name, true, it.help).apply + { setArgs(Option.UNLIMITED_VALUES) }) + } (STRING_OPTIONS + TIME_OPTIONS).forEach { addOption(Option(null, it.name, true, it.help).apply { setArgs(Option.UNLIMITED_VALUES) }) @@ -66,7 +72,7 @@ throw SubcommandException(message = "unexpected trailing arguments", status = 2) } - STRING_OPTIONS.forEach { + (ABBREV_STRING_OPTIONS + STRING_OPTIONS).forEach { commandLine.getOptionValues(it.name)?.forEach { value -> val regexOptions = mutableSetOf() if (commandLine.hasOption(FIXED)) {