Manfred,
The development alias is probably not the best for this.
However, one quick answer is the "ids" command. In my scripts, I do this:
task rc.verbose=nothing ids | sed "s/^1[-]//g"
It returns the IDs matching a filter, and without a filter just returns the entire range. Since the newly created task is the newest one, then the last ID is it.
Be advised that this will only work for serial scripts. Any parallel processing will create a race condition, since the tasks file may be modified by another process between the creation and ID check of the first process. In that case, you may do something like:
task rc.verbose=new-uuid add [...]
You can then parse the result of this command. Note that the "taskrc" man page says that the "new-uuid" command is deprecated and will be merged with "new-id", so you will have to update your script at some future version.
I hope this helps.
-- Gary
------------------------------
> Date: Mon, 17 Jun 2019 12:21:34 -0700 (PDT)
> From: Manfred Lotz <
being.a...@gmail.com>
> To: taskwarrior-dev <
taskwar...@googlegroups.com>
> Subject: [taskwarrior-dev] How to create a task and then an annotation in a
> script?
>
> In a script I want to create a task and then an annotation to the just created task. For the annoatation I need the task number.
>
> How can I do this?
>
> --
> You received this message because you are subscribed to the Google Groups "taskwarrior-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
taskwarrior-d...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/taskwarrior-dev/3bc8f088-9fb6-4946-bb23-bf64392f4e87%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.