modify_property: Modify Task Property

View source: R/update.R

modify_propertyR Documentation

Modify Task Property

Description

This is a package internal function used to modify a task given an input and a task to be modified. Because the tasks all are simple textual strings, modification is implemented by text substitution and then re-parsing of the task.

The function presumes that all modifications of properties can be based on strings like "prop:value" (wherein underscores represent a space). Thus, strictly speaking, tags are not properties of a task.

To implement a degree of flexibility in how to specify properties and values, prop defaults to NULL so that value can (also) be used to specify new values as prop:value.

Also in view of flexibility, the function presumes that the user ensures to maintain the todo.txt specification. So no checking is done to ascertain whether a property is a valid property of the (original) specification.

Note that setting the property (of which always only one should exist in any given task) and new value suitable also enables deleting properties from a task. For instance, modify_property(task, "due:", "") removes the due date from a task. Does not work yet.

Usage

modify_property(task, prop = NULL, value)

Arguments

task

A string with one (or, as vector, one or more) task(s) that follow(s) the todo.txt specification by Gina Trapani. When multiple tasks are provided, all tasks are modified in the same way.

prop

Identifier of the property of the task (a string). Can be postfixed with a colon (e.g. "due:" instead of "due"). Defaults to NULL implying that then value needs to be specified as property:value instead of only value.

value

New value for the property (a string).

Value

The updated task(s)

Author(s)

Paul Lemmens (paul.lemmens@gmail.com)


paullemmens/todoRtxt documentation built on May 19, 2023, 3:21 p.m.