annotate src/main/kotlin/name/blackcap/passman/ListSubcommand.kt @ 24:2188b2f13326

Make some minor tweaks to the help system.
author David Barts <n5jrn@me.com>
date Wed, 03 Jul 2024 17:14:22 -0700
parents 07406c4af4a5
children 69526ae8c8de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
1 package name.blackcap.passman
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
2
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
3 import org.apache.commons.cli.*
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
4 import java.util.regex.PatternSyntaxException
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
5
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
6 class ListSubcommand(): Subcommand() {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
7 private companion object {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
8 const val CASE = "case"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
9 const val FIXED = "fixed"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
10 const val HELP = "help"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
11 const val LONG = "long"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
12 const val NAME = "name"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
13 const val NOTES = "notes"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
14 const val USERNAME = "username"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
15 const val ACCESSED = "accessed"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
16 const val CREATED = "created"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
17 const val MODIFIED = "modified"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
18 val FLAG_OPTIONS = listOf<OptionDescriptor>(
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
19 OptionDescriptor(CASE, "Treat upper and lower case as distinct."),
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
20 OptionDescriptor(FIXED, "Match fixed substrings instead of regular expressions."),
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
21 OptionDescriptor(HELP, "Print this help message."),
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
22 OptionDescriptor(LONG, "Long format listing.")
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
23 )
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
24 val STRING_OPTIONS = listOf<OptionDescriptor>(
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
25 OptionDescriptor(NAME, "Match site name."),
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
26 OptionDescriptor(NOTES, "Match notes."),
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
27 OptionDescriptor(USERNAME, "Match username.")
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
28 )
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
29 val TIME_OPTIONS = listOf<OptionDescriptor>(
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
30 OptionDescriptor(ACCESSED, "Match time password last read."),
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
31 OptionDescriptor(CREATED, "Match time created."),
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
32 OptionDescriptor(MODIFIED, "Match time last modified.")
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
33 )
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
34 val REDACTED = "(redacted)".toCharArray()
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
35 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
36 private lateinit var commandLine: CommandLine
7
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
37 private val matchers = mutableMapOf<String, MutableList<(Any?) -> Boolean>>()
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
38
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
39 private data class OptionDescriptor(val name: String, val help: String)
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
40
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
41 override fun run(args: Array<String>) {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
42 parseArgs(args)
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
43 runQuery()
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
44 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
45
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
46 private fun parseArgs(args: Array<String>): Unit {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
47 val options = Options().apply {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
48 FLAG_OPTIONS.forEach {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
49 addOption(it.name.first().toString(), it.name, false, it.help)
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
50 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
51 (STRING_OPTIONS + TIME_OPTIONS).forEach {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
52 addOption(Option(null, it.name, true, it.help).apply
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
53 { setArgs(Option.UNLIMITED_VALUES) })
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
54 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
55 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
56 try {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
57 commandLine = DefaultParser().parse(options, args)
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
58 } catch (e: ParseException) {
21
ea65ab890f66 More work to support interactive feature.
David Barts <n5jrn@me.com>
parents: 9
diff changeset
59 throw SubcommandException(message = e.message ?: "syntax error", cause = e, status = 2)
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
60 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
61 if (commandLine.hasOption(HELP)) {
9
72619175004e Fix issues found in testing.
David Barts <n5jrn@me.com>
parents: 8
diff changeset
62 HelpFormatter().printHelp("$SHORTNAME list [options]", options)
22
07406c4af4a5 More interactive mode stuff.
David Barts <n5jrn@me.com>
parents: 21
diff changeset
63 throw SubcommandException(status = 0)
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
64 }
8
698c4a3d758d Some code clean-up.
David Barts <n5jrn@me.com>
parents: 7
diff changeset
65 if (commandLine.args.isNotEmpty()) {
21
ea65ab890f66 More work to support interactive feature.
David Barts <n5jrn@me.com>
parents: 9
diff changeset
66 throw SubcommandException(message = "unexpected trailing arguments", status = 2)
8
698c4a3d758d Some code clean-up.
David Barts <n5jrn@me.com>
parents: 7
diff changeset
67 }
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
68
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
69 STRING_OPTIONS.forEach {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
70 commandLine.getOptionValues(it.name)?.forEach { value ->
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
71 val regexOptions = mutableSetOf<RegexOption>()
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
72 if (commandLine.hasOption(FIXED)) {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
73 regexOptions.add(RegexOption.LITERAL)
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
74 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
75 if (!commandLine.hasOption(CASE)) {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
76 regexOptions.add(RegexOption.IGNORE_CASE)
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
77 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
78 try {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
79 if (it.name !in matchers) {
7
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
80 matchers[it.name] = mutableListOf<(Any?) -> Boolean>()
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
81 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
82 matchers[it.name]!! += { x -> x is String && x.contains(Regex(value, regexOptions)) }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
83 } catch (e: PatternSyntaxException) {
21
ea65ab890f66 More work to support interactive feature.
David Barts <n5jrn@me.com>
parents: 9
diff changeset
84 throw SubcommandException(message = "${see(value)} - invalid regular expression", cause = e, status = 2)
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
85 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
86 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
87 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
88
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
89 TIME_OPTIONS.forEach {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
90 commandLine.getOptionValues(it.name)?.forEach { rawValue ->
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
91 if (rawValue.isEmpty()) {
21
ea65ab890f66 More work to support interactive feature.
David Barts <n5jrn@me.com>
parents: 9
diff changeset
92 throw SubcommandException(message = "empty string is not a valid time expression")
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
93 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
94 val (op, exp) = when(rawValue.first()) {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
95 '+', '>' -> Pair<Char, String>('>', rawValue.substring(1))
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
96 '=' -> Pair<Char, String>('=', rawValue.substring(1))
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
97 '-', '<' -> Pair<Char, String>('<', rawValue.substring(1))
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
98 else -> Pair<Char, String>('=', rawValue)
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
99 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
100 val value = parseDateTime(exp)
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
101 if (value == null) {
21
ea65ab890f66 More work to support interactive feature.
David Barts <n5jrn@me.com>
parents: 9
diff changeset
102 throw SubcommandException(message = "${see(rawValue)} - invalid time expression")
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
103 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
104 if (it.name !in matchers) {
7
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
105 matchers[it.name] = mutableListOf<(Any?) -> Boolean>()
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
106 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
107 when(op) {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
108 '>' -> matchers[it.name]!! += { x -> x is Long && x > value }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
109 '=' -> matchers[it.name]!! += { x -> x is Long && (x/1000L) == (value/1000L) }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
110 '<' -> matchers[it.name]!! += { x -> x is Long && x < value }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
111 else -> throw RuntimeException("should never happen")
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
112 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
113 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
114 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
115 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
116
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
117 private fun runQuery(): Unit {
21
ea65ab890f66 More work to support interactive feature.
David Barts <n5jrn@me.com>
parents: 9
diff changeset
118 val db = Database.default
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
119
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
120 db.connection.prepareStatement("select $NAME, $USERNAME, $NOTES, $CREATED, $MODIFIED, $ACCESSED from passwords").use {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
121 val results = it.executeQuery()
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
122 val printer = if (commandLine.hasOption(LONG)) Entry::printLong else Entry::print
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
123 var count = 0;
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
124 while (results.next()) {
7
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
125 val entry = Entry(
8
698c4a3d758d Some code clean-up.
David Barts <n5jrn@me.com>
parents: 7
diff changeset
126 name = results.getDecryptedString(1, db.encryption)!!,
698c4a3d758d Some code clean-up.
David Barts <n5jrn@me.com>
parents: 7
diff changeset
127 username = results.getDecryptedString(2, db.encryption)!!,
7
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
128 password = REDACTED,
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
129 notes = results.getDecryptedString(3, db.encryption),
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
130 created = results.getDate(4),
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
131 modified = results.getDate(5),
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
132 accessed = results.getDate(6)
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
133 )
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
134 val passed = matchers
7
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
135 .map { x -> x.value.fold(true) {
f245b9a53495 Efficiency improvements.
David Barts <n5jrn@me.com>
parents: 6
diff changeset
136 acc, pred -> acc && pred(entry.getField(x.key)) } }
6
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
137 .reduceOrNull() { a, b -> a && b }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
138 ?: true
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
139 if (passed) {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
140 if (count > 0) {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
141 println()
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
142 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
143 printer(entry, null)
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
144 count++
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
145 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
146 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
147 val s = if (count == 1) "" else "s"
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
148 if (count > 0) {
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
149 println()
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
150 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
151 println("$count record$s found")
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
152 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
153 }
711cc42e96d7 Got the list subcommand working, but needs efficiency improvements.
David Barts <n5jrn@me.com>
parents:
diff changeset
154 }