3arthqu4ke / headlessmc

Minecraft on the command line
https://3arthqu4ke.github.io/headlessmc/
MIT License
142 stars 16 forks source link

Multi command inquiry/issue #130

Closed JewFrags closed 6 months ago

JewFrags commented 6 months ago

I'm having trouble using the multi command, how do I use a command that requires a specified field without that field being picked up as a separate command? (didn't find much documentation regarding this, also I tried quotes but my syntax is probably wrong) so for example: "--command mutli login " both passwd/email fields are treated as separate commands for me.

3arthqu4ke commented 6 months ago

The command system and documentation is not the greatest, I will have to rework them a bit at some point...

To use the multicommand you need to escape a lot with ": multi "<command 1>" "<command 2>" ...

Escaping works this way: Commands take multiple args. Spaces are used to seperate args, so as soon as something contains a space its two args, unless you surround it with ". If you want to use a " inside an arg, without ending it, you need to escape it with a \. You can also escape spaces with \, so you can also use \ to escape every space as an alternative to ".

JewFrags commented 6 months ago

Sounds good, makes sense but am I missing something here specifically?

❯ java -jar .\headlessmc-launcher-1.8.1.jar --command multi "launch 1.12.2-forge-14.23.5.2860"
Please specify a Version!
Couldn't find command for '[1.12.2-forge-14.23.5.2860]', did you mean 'forge'?
3arthqu4ke commented 6 months ago

Ah, I see, the java command splits the given String into the famous String[] args, so you actually need to escape twice, once for java, once for headlessmc. This might be specific to your OS/Shell, but this worked for me, using ' for java and " for headlessmc:

java -jar .\headlessmc-launcher-1.9.1.jar 'multi "<command 1>" "<command 2>"'