shared usage printer

This commit is contained in:
Gilles Boccon-Gibod
2023-12-04 00:37:28 -08:00
parent 0ed6aa230b
commit 8400ff0802

View File

@@ -4,19 +4,24 @@ import java.io.IOException
class CommandLineInterface { class CommandLineInterface {
companion object { companion object {
fun printUsage() {
System.out.println("usage: <launch-command> [-h|--help] [<tcp-port>]")
}
@JvmStatic fun main(args: Array<String>) { @JvmStatic fun main(args: Array<String>) {
System.out.println("Starting proxy") System.out.println("Starting proxy")
var tcpPort = DEFAULT_TCP_PORT var tcpPort = DEFAULT_TCP_PORT
if (args.isNotEmpty()) { if (args.isNotEmpty()) {
if (args[0] == "-h" || args[0] == "--help") { if (args[0] == "-h" || args[0] == "--help") {
System.out.println("usage: <launch-command> [-h|--help] [<tcp-port>]") printUsage()
return return
} }
try { try {
tcpPort = args[0].toInt() tcpPort = args[0].toInt()
} catch (error: NumberFormatException) { } catch (error: NumberFormatException) {
System.out.println("ERROR: invalid TCP port argument") System.out.println("ERROR: invalid TCP port argument")
printUsage()
return return
} }
} }