mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
fix printing of help arguments
This commit is contained in:
parent
3a413352d9
commit
5879f10856
@ -13,14 +13,17 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.terminal
|
package de.bixilon.minosoft.terminal
|
||||||
|
|
||||||
|
import de.bixilon.kutil.shutdown.AbstractShutdownReason
|
||||||
|
import de.bixilon.kutil.shutdown.ShutdownManager
|
||||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||||
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import net.sourceforge.argparse4j.ArgumentParsers
|
import net.sourceforge.argparse4j.ArgumentParsers
|
||||||
import net.sourceforge.argparse4j.impl.Arguments
|
import net.sourceforge.argparse4j.impl.Arguments
|
||||||
import net.sourceforge.argparse4j.inf.ArgumentParserException
|
import net.sourceforge.argparse4j.inf.ArgumentParserException
|
||||||
import net.sourceforge.argparse4j.inf.Namespace
|
import net.sourceforge.argparse4j.inf.Namespace
|
||||||
import kotlin.system.exitProcess
|
import java.io.PrintWriter
|
||||||
|
|
||||||
object CommandLineArguments {
|
object CommandLineArguments {
|
||||||
lateinit var ARGUMENTS: List<String>
|
lateinit var ARGUMENTS: List<String>
|
||||||
@ -92,8 +95,8 @@ object CommandLineArguments {
|
|||||||
try {
|
try {
|
||||||
namespace = PARSER.parseArgs(args)
|
namespace = PARSER.parseArgs(args)
|
||||||
} catch (exception: ArgumentParserException) {
|
} catch (exception: ArgumentParserException) {
|
||||||
PARSER.handleError(exception)
|
PARSER.handleError(exception, PrintWriter(Log.FATAL_PRINT_STREAM))
|
||||||
exitProcess(1)
|
return ShutdownManager.shutdown(reason = AbstractShutdownReason.CRASH)
|
||||||
}
|
}
|
||||||
|
|
||||||
RunConfiguration.LOG_COLOR_MESSAGE = namespace.getBoolean("disable_log_color_message")
|
RunConfiguration.LOG_COLOR_MESSAGE = namespace.getBoolean("disable_log_color_message")
|
||||||
|
@ -80,7 +80,7 @@ object Log {
|
|||||||
messageToSend.message.setFallbackColor(messageColor)
|
messageToSend.message.setFallbackColor(messageColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
val stream = if (messageToSend.logMessageType.error) {
|
val stream = if (messageToSend.level.error) {
|
||||||
SYSTEM_ERR_STREAM
|
SYSTEM_ERR_STREAM
|
||||||
} else {
|
} else {
|
||||||
SYSTEM_OUT_STREAM
|
SYSTEM_OUT_STREAM
|
||||||
|
@ -17,9 +17,9 @@ import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
|||||||
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
import de.bixilon.minosoft.data.text.formatting.color.Colors
|
||||||
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
import de.bixilon.minosoft.data.text.formatting.color.RGBColor
|
||||||
|
|
||||||
enum class LogLevels(val levelColors: RGBColor) {
|
enum class LogLevels(val levelColors: RGBColor, val error: Boolean = false) {
|
||||||
FATAL(Colors.DARK_RED),
|
FATAL(Colors.DARK_RED, true),
|
||||||
WARN(ChatColors.RED),
|
WARN(ChatColors.RED, true),
|
||||||
INFO(ChatColors.WHITE),
|
INFO(ChatColors.WHITE),
|
||||||
VERBOSE(ChatColors.YELLOW),
|
VERBOSE(ChatColors.YELLOW),
|
||||||
;
|
;
|
||||||
|
@ -21,7 +21,6 @@ enum class LogMessageType(
|
|||||||
val defaultColor: RGBColor,
|
val defaultColor: RGBColor,
|
||||||
val colorMap: Map<LogLevels, RGBColor> = emptyMap(),
|
val colorMap: Map<LogLevels, RGBColor> = emptyMap(),
|
||||||
val defaultLevel: LogLevels = LogLevels.INFO,
|
val defaultLevel: LogLevels = LogLevels.INFO,
|
||||||
val error: Boolean = false,
|
|
||||||
) {
|
) {
|
||||||
AUTO_CONNECT(ChatColors.WHITE),
|
AUTO_CONNECT(ChatColors.WHITE),
|
||||||
GENERAL(ChatColors.WHITE),
|
GENERAL(ChatColors.WHITE),
|
||||||
|
@ -34,4 +34,8 @@ class LogPrintStream(
|
|||||||
}
|
}
|
||||||
Log.log(message = string, type = type, level = level)
|
Log.log(message = string, type = type, level = level)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun write(buf: ByteArray, off: Int, len: Int) {
|
||||||
|
print(String(buf).substring(off, len)) // ToDo: Optimize
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user