How can I create a task using nexus script

As described from the title. I want to do my job which adding a task automaticly. Any tips are welcome!

The answer to this will be a useful addition to Advanced Use Cases for the Nexus Repository Manager API