1.4.0 release #9

Merged
Infendro merged 20 commits from develop into main 2026-01-10 07:37:21 +00:00
10 changed files with 21 additions and 15 deletions
Showing only changes of commit f33caa30c0 - Show all commits

View File

@@ -20,7 +20,7 @@ sealed class Command private constructor(
internal val renderer: HelpRenderer,
) {
init {
if (!name.matches(Regex.COMMAND)) throw InvalidCommand(name)
if (!name.matches(Regex.COMMAND)) throw InvalidCommandName(name)
}
fun run(args: Array<String>) {

View File

@@ -1,6 +1,6 @@
package com.infendro.cli.command.argument
import com.infendro.cli.error.build.InvalidArgument
import com.infendro.cli.error.build.InvalidArgumentName
import com.infendro.cli.error.build.InvalidRange
import com.infendro.cli.parser.Parser
import com.infendro.cli.util.Regex.ARGUMENT
@@ -13,7 +13,7 @@ sealed class Argument<T : Any>(
) {
init {
when {
!name.matches(ARGUMENT) -> throw InvalidArgument(name)
!name.matches(ARGUMENT) -> throw InvalidArgumentName(name)
min !in 0..count || max == 0 -> throw InvalidRange()
}
}

View File

@@ -1,6 +1,6 @@
package com.infendro.cli.command.option
import com.infendro.cli.error.build.InvalidOption
import com.infendro.cli.error.build.InvalidOptionName
import com.infendro.cli.error.build.InvalidRange
import com.infendro.cli.error.build.MissingOptionName
import com.infendro.cli.parser.Parser
@@ -35,7 +35,7 @@ sealed class Option<T : Any>(
init {
when {
names.isEmpty() -> throw MissingOptionName()
names.any { !it.matches(OPTION) } -> throw InvalidOption(name)
names.any { !it.matches(OPTION) } -> throw InvalidOptionName(name)
min !in 0..count || max == 0 -> throw InvalidRange()
}
}

View File

@@ -1,3 +1,3 @@
package com.infendro.cli.error.build
abstract class BuildException : Error()
abstract class BuildException : Exception()

View File

@@ -1,8 +1,10 @@
package com.infendro.cli.error.build
import com.infendro.cli.command.argument.Argument
class DuplicateArgument(
val name: String,
val argument: Argument<*>,
) : BuildException() {
override val message: String
get() = """duplicate argument "$name""""
get() = """duplicate argument "${argument.name}""""
}

View File

@@ -1,8 +1,10 @@
package com.infendro.cli.error.build
import com.infendro.cli.command.Command
class DuplicateCommand(
val command: String,
val command: Command,
) : BuildException() {
override val message: String
get() = """duplicate command "$command""""
get() = """duplicate command "${command.name}""""
}

View File

@@ -1,8 +1,10 @@
package com.infendro.cli.error.build
import com.infendro.cli.command.option.Option
class DuplicateOption(
val name: String,
val option: Option<*>,
) : BuildException() {
override val message: String
get() = """duplicate option "$name""""
get() = """duplicate option "${option.name}""""
}

View File

@@ -1,6 +1,6 @@
package com.infendro.cli.error.build
class InvalidArgument(
class InvalidArgumentName(
val name: String,
) : BuildException() {
override val message: String

View File

@@ -1,6 +1,6 @@
package com.infendro.cli.error.build
class InvalidCommand(
class InvalidCommandName(
val name: String,
) : BuildException() {
override val message: String

View File

@@ -1,6 +1,6 @@
package com.infendro.cli.error.build
class InvalidOption(
class InvalidOptionName(
val name: String,
) : BuildException() {
override val message: String