Possible? Macro for updating a document in headless from the linked template

Hi all,

I need to batch-update documents in headless mode, when the linked template changes.

https://ask.libreoffice.org/t/updating-documents-from-template-with-soffice-in-headless-mode/79218
https://ask.libreoffice.org/t/headless-accept-all-changes-in-writer-document/69819

Since I could not find a command line argument for achieving this, I think that I could write a macro and call that macro from the command line.

I never wrote any LibreOffice macros. Is it possible to write a macro that does what I need?

Best regards,
DomCa