The best scenario we can hope for is for generals to simply refuse an illegal order, and when told to retire, refuse, and when reassigned to also refuse on the grounds that it's illegal punishment for refusing an illegal order.
Anything more and you're in coup territory, which sets the precedent that the military can step in and "correct" civilian government when it's wrong in their view. See, for example, Myanmar. Even after the military relinquished control to allow democracy, they still decided to "correct" that democracy when it started to drift from their wishes.