It would be a strange command indeed if she was really betrothed to the Holy Spirit and considered to be e spouse of the Holy Spirit.
They want us to think the Holy Spirit encouraged Joseph and Mary to commit adultery...
True, because in that culture, the betrothal was considered marriage, a done deal even though it had not yet been consumated.
Otherwise Joseph would not have considered divorcing Mary for her perceived infidelity.
A different word than divorce would have been used to explain Joseph’s actions for breaking off the engagement if it had not had the same status as marriage.