A command usually gets input from the selection list. The result of the MGlobal::getActiveSelectionList() method contains all selected objects and can easily be checked through MSelectionList and MItSelectionList—two API classes you can use to edit selection lists.