The final judgment in such action or proceeding shall either dismiss the action or proceeding or direct that the writ of mandamus or injunction issue or be made permanent as prayed for in the petition, or in such modified or other form as will afford appropriate relief.