playdate.argv behaves differently between MacOS and Linux (as of SDK 1.13.7). For example, assuming I want to launch whatever.pdx
in the simulator and pass something
as an argument then I'll run:
PlaydateSimulator whatever.pdx something
and my lua script just prints to the console with:
printTable(playdate.argv)
On Linux
# PlaydateSimulator whatever.pdx something
{
something
}
On MacOS playdate.argv
gives two or three elements depending on how the simulator is invoked:
# alias PlaydateSimulator="$HOME/Developer/PlaydateSDK/bin/Playdate\ Simulator.app/Contents/MacOS/Playdate\ Simulator"
# PlaydateSimulator whatever.pdx something
{
/Users/peter/Developer/PlaydateSDK/bin/Playdate\ Simulator.app/Contents/MacOS/Playdate\ Simulator,
whatever.pdx,
something,
}
# open whatever.pdx --args something
{
/Users/peter/Developer/PlaydateSDK/bin/Playdate\ Simulator.app/Contents/MacOS/Playdate\ Simulator,
something,
}
I haven't tested Windows, but this thread suggested the Windows SDK may not implement playdate.argv
at all. (worth documenting if still true)
This came up because I am trying to use Docker based CI (see: Headless Simulator - #5 by joyrider3774) to automate screenshot creation. (coming soon!)
The Linux API feels more ergonomic, but I think the MacOS 3 element most closely matches argv in C. Honestly I have no strong opinions other than it should be consistent. This might be worth exposing the unified behavior under a new API (e.g. playdate.simulator.argv
) and deprecate playdate.argv
but that might be overkill.
Thanks all!