The pleadings and other proceedings in any action in which a mandamus is claimed shall be the same, as nearly as may be, and costs shall be recoverable by either party, as in an ordinary action for the recovery of damages.