Nikky
02/25/2022, 11:18 AMBig Chungus
02/25/2022, 12:30 PMBig Chungus
02/25/2022, 12:31 PMBig Chungus
02/25/2022, 12:32 PMBig Chungus
02/25/2022, 12:33 PMNikky
02/25/2022, 2:07 PM/** Returns the path to the executing binary. */
val fullBinaryPath: String by lazy {
    memScoped {
        val length = PATH_MAX.toULong()
        val pathBuf = allocArray<ByteVar>(length.toInt())
        val myPid = getpid()
        val res = readlink("/proc/$myPid/exe", pathBuf, length)
        if (res < 1)
            throw RuntimeException("/proc/$myPid/exe failed: $res")
        pathBuf.toKString()
    }
}class MyCommand(binary: String) : CliktCommand(
    name = fullBinaryPath.substringAfterLast("/"),
    invokeWithoutSubcommand = false
) {
...
}
fun main(vararg args: String) {
    ...
    
    MyCommand().main(args)
}Big Chungus
02/25/2022, 2:43 PMBig Chungus
02/25/2022, 2:44 PMRob Elliot
02/25/2022, 2:56 PMI don't think that's even possible in native world in general.Pretty sure
argv[0]Nikky
02/25/2022, 3:24 PMRob Elliot
02/25/2022, 3:25 PM