How to use a limit switch to trigger a command?

If I have a limit switch, how do I program it so when it gets pressed down a command is run?

Make a class which extends “Trigger”, in the get() method return the value of the limit switch. Make an instance of Trigger, which you can treat similar to an instance of Button.