refactor argument system

- arguments can have multiple names simultaneously
- argument values can be passed using spaces (e.g., --arg value)
- single-character arguments can be passed using a single dash (e.g., --a -> -a)
- multiple single-character arguments can be combined (e.g., -a -b -> -ab)
- simplify custom arguments using generic classes
This commit is contained in:
2025-12-27 17:30:05 +01:00
parent 6be1957d82
commit 79629ae68d
17 changed files with 258 additions and 388 deletions

View File

@@ -1,7 +1,6 @@
package com.infendro.cli.util
internal object Regex {
val COMMAND_NAME = """[a-z]+(?:-[a-z]+)*""".toRegex()
val ARGUMENT_NAME = """[a-z]+(?:[\-.][a-z]+)*""".toRegex()
val ARGUMENT = """--(?<name>[a-z]+(?:[\-.][a-z]+)*)(?:=(?<value>.*))?""".toRegex()
val COMMAND_NAME = Regex("""[a-z]+(?:-[a-z]+)*""")
val ARGUMENT_NAME = Regex("""[a-z]+(?:[\-.][a-z]+)*""")
}