CLI reference

The module provides a command-line interface for managing tasks.

You can run the commands using the tasks command followed by the specific subcommand:

cusy.tasks add "My task description" --owner "Veit"
cusy.tasks list
cusy.tasks list --owner "Veit" --state "todo"
cusy.tasks update 1 --owner "Veit" --summary "Update description"
cusy.tasks start 1
cusy.tasks finish 1
cusy.tasks delete 1
cusy.tasks count
cusy.tasks config
cusy.tasks version

If no subcommand is specified, the list command is executed by default.

cusy.tasks.cli.version()[source]

Return the version of the tasks application.

Returns:

The version string of the tasks package.

Return type:

str

cusy.tasks.cli.add(summary: list[str], owner: str = <typer.models.OptionInfo object>)[source]

Add a task to the database.

Parameters:
  • summary (list[str]) – The summary of the new task.

  • owner (str, optional) – The owner of the new task. Defaults to None.

cusy.tasks.cli.delete(task_id: int)[source]

Remove a task from the database.

Parameters:

task_id (int) – The ID of the task to delete.

Raises:

InvalidTaskIdError – If no task with the given ID exists.

cusy.tasks.cli.list_tasks(owner: str = <typer.models.OptionInfo object>, state: str = <typer.models.OptionInfo object>)[source]

List tasks in the database, optionally filtered by owner and/or state.

Parameters:
  • owner (str, optional) – Filter tasks by this owner. Defaults to None.

  • state (str, optional) – Filter tasks by this state. Defaults to None.

cusy.tasks.cli.update(task_id: int, owner: str = <typer.models.OptionInfo object>, summary: list[str] = <typer.models.OptionInfo object>)[source]

Update a task in the database.

Parameters:
  • task_id (int) – The ID of the task to update.

  • owner (str, optional) – The new owner of the task. Defaults to None.

  • summary (list[str], optional) – The new summary of the task. Defaults to None.

Raises:

InvalidTaskIdError – If no task with the given ID exists.

cusy.tasks.cli.start(task_id: int)[source]

Set a task’s state to ‘in progress’.

Parameters:

task_id (int) – The ID of the task to update.

Raises:

InvalidTaskIdError – If no task with the given ID exists.

cusy.tasks.cli.finish(task_id: int)[source]

Set a task’s state to ‘done’.

Parameters:

task_id (int) – The ID of the task to update.

Raises:

InvalidTaskIdError – If no task with the given ID exists.

cusy.tasks.cli.config()[source]

Return the path to the Tasks database.

Returns:

Path to the Tasks database.

Return type:

str

cusy.tasks.cli.count()[source]

Return the number of tasks in the database.

Returns:

Number of tasks in the database.

Return type:

int

cusy.tasks.cli.get_path()[source]

Determine the path to the database.

The path is determined from the environment variable ITEMS_DB_DIR. If it is not defined, $HOME/tasks_db is used.

Returns:

Path to the database directory.

Return type:

pathlib.Path

cusy.tasks.cli.tasks_db()[source]

Open and close the database connection.

Yields:

TasksDB – A TasksDB instance connected to the database.