Move until endstop is also known as homing which is implemented with G28. You can do it with x,y and z.
For own commands you can add a event for unknown commands (see events.h description) or change in commands.cpp the mcode function and add one more case.