Rewrite emr-declare-command as function, update usages