-
Notifications
You must be signed in to change notification settings - Fork 280
Description
As it stands, the command line syntax is fairly limited. The syntax can be seen in my PR in #106. There are no control loops nor delays, and commands have to be either typed manually or be in a single line and executed sequentially, one after the other, without pause.
Proposal
- Multiple commands in a single line using
;. The current syntax uses&&to achieve this, thus;may be treated as a synonym. - Commands are to be case-insensitive. That is,
A; NFC file_name,a && nfc file_nameanda ; nfC file_name(although the last one will look weird) should perform the same task. - Addition of
sleep, with syntaxsleep interval(intervalas a float in seconds), which just tells the interpreter to pause/sleep for some amount of time.a; sleep 5; bwill signal to the Switch to press theAbutton, wait for 5 seconds, and then press theBbutton. - For loops. This has been mentioned before in 请问循环语法可以填写无限循环吗? #84, although in Chinese. Proposing the following syntax:
for COUNT ; commands ; donewill repeatcommandsCOUNTtimes. Example usage:for 10; a; sleep 1; b; sleep 1; done, will causeA,B,A,B, and so on to be pressed, (ideally) 1 second apart.- For loops can also be inside for loops:
for 10; a; sleep 1; for 10; b; sleep 1; done; sleep 1; done, or graphically:
- For loops can also be inside for loops:
for 10
a
sleep 1
for 10
b
sleep 1
done
sleep 1
done
- For loops with delay:
for COUNT DELAY; cmd1; cmd2; doneis the same asfor COUNT; cmd1; sleep DELAY; cmd2; sleep DELAY; done. - "Reading" from files using
read file_path, which parses a filefile_paththat looks like the code block above. Comments would start with#'s. - Macros: Setting a macro using
macro mname; cmd1; cmd2; doneand using it likefor COUNT; mname; done.mnameshouldn't be a "reserved keyword", and be limited to not having spaces. Parameterized macros can be a thing in the future.
Breaking changes
Applications or people that already use joycontrolmust be able to still use it after the changes have been made. Nonetheless, the changes provided may introduce some bugs along the way
The addition of ; and # as key symbols and setting all commands to case-insensitive may cause issues with file_names. An intelligent parser should be able to parse the new commands.
Further changes
Comments about this proposal are welcome. I wouldn't want to make the syntax too complex, so I want this proposal to be as concise as possible. For instance, I wouldn't want to add conditional execution (if blocks) since it wouldn't really be useful.