joycontrol
joycontrol copied to clipboard
Extending joycontrol command line syntax
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_name
anda ; nfC file_name
(although the last one will look weird) should perform the same task. - Addition of
sleep
, with syntaxsleep interval
(interval
as a float in seconds), which just tells the interpreter to pause/sleep for some amount of time.a; sleep 5; b
will signal to the Switch to press theA
button, wait for 5 seconds, and then press theB
button. - For loops. This has been mentioned before in #84, although in Chinese. Proposing the following syntax:
for COUNT ; commands ; done
will repeatcommands
COUNT
times. 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; done
is the same asfor COUNT; cmd1; sleep DELAY; cmd2; sleep DELAY; done
. - "Reading" from files using
read file_path
, which parses a filefile_path
that looks like the code block above. Comments would start with#
's. - Macros: Setting a macro using
macro mname; cmd1; cmd2; done
and using it likefor COUNT; mname; done
.mname
shouldn'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 joycontrol
must 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_name
s. 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.
I dont like putting the commands in the command line. I do like the suggestion of having all these commands in a file, with comments starting with # like mentioned.
I dont like putting the commands in the command line.
What do you mean by "commands"?