Skip to content

Commit 86faa0b

Browse files
Merge branch 'dev'
2 parents 605ad55 + 2c1c7ae commit 86faa0b

File tree

11 files changed

+403
-9
lines changed

11 files changed

+403
-9
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ Alternatively, you can install from source:
7878
The library supports configuration via environment variables:
7979

8080
- `CALDAV_TASKS_API_URL`: CalDAV server URL
81-
- `CALDAV_TASKS_API_USERNAME`: CalDAV username
81+
- `CALDAV_TASKS_API_USERNAME`: CalDAV username
8282
- `CALDAV_TASKS_API_PASSWORD`: CalDAV password
8383
- `CALDAV_TASKS_API_DEFAULT_LIST_UID`: Default task list UID for operations
84+
- `CALDAV_TASKS_API_DEFAULT_PRIORITY`: Default priority to use when creating tasks
85+
- `CALDAV_TASKS_API_LOG_LEVEL`: Default log level, by default `WARNING`
8486

8587
## Usage
8688

@@ -101,6 +103,9 @@ python -m caldav_tasks_api list-lists
101103
# List latest tasks from a specific list
102104
python -m caldav_tasks_api list-latest-tasks --list-uid <list-uid>
103105
106+
# Dump all the tasks of a list as VTODO format
107+
python -m caldav_tasks_api dump-all-tasks --list-uid <list-uid>
108+
104109
# Add a new task
105110
python -m caldav_tasks_api add-task --list-uid <list-uid> --summary "My new task"
106111

bumpver.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
[bumpver]
3-
current_version = "1.2.4"
3+
current_version = "1.3.0"
44
version_pattern = "MAJOR.MINOR.PATCH"
55
commit_message = "bump version {old_version} -> {new_version}"
66
tag_message = "{new_version}"

caldav_tasks_api/__main__.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,5 +544,107 @@ def list_lists(url, username, password, nextcloud_mode, debug):
544544
raise click.Abort()
545545

546546

547+
@cli.command(name="dump-all-tasks")
548+
@click.option("--url", help="CalDAV server URL (or set CALDAV_URL env var)")
549+
@click.option("--username", help="CalDAV username (or set CALDAV_USERNAME env var)")
550+
@click.option("--password", help="CalDAV password (or set CALDAV_PASSWORD env var)")
551+
@click.option(
552+
"--nextcloud-mode/--no-nextcloud-mode",
553+
default=True,
554+
help="Adjust URL for Nextcloud specific path [default: enabled]",
555+
)
556+
@click.option(
557+
"--debug/--no-debug",
558+
default=False,
559+
help="Enable debug mode with interactive console [default: disabled]",
560+
)
561+
@click.option(
562+
"--list-uid",
563+
default=None,
564+
envvar="CALDAV_TASKS_API_DEFAULT_LIST_UID",
565+
help="UID of the task list to dump all tasks from. Defaults to CALDAV_TASKS_API_DEFAULT_LIST_UID env var if set.",
566+
)
567+
def dump_all_tasks(url, username, password, nextcloud_mode, debug, list_uid):
568+
"""Dump all tasks from a specified list in VTODO format."""
569+
logger.debug(
570+
f"CLI dump-all-tasks initiated with url: {'***' if url else 'from env'}, "
571+
f"user: {username or 'from env'}, nc_mode: {nextcloud_mode}, "
572+
f"debug: {debug}, list_uid: {list_uid}"
573+
)
574+
575+
if not list_uid:
576+
click.echo(
577+
"Error: Task list UID must be provided via --list-uid argument or CALDAV_TASKS_API_DEFAULT_LIST_UID environment variable.",
578+
err=True,
579+
)
580+
raise click.Abort()
581+
582+
try:
583+
# This command is inherently read-only.
584+
# Filter to only the specified list to optimize loading
585+
api = get_api(
586+
url,
587+
username,
588+
password,
589+
nextcloud_mode,
590+
debug,
591+
target_lists=[list_uid],
592+
read_only=True,
593+
)
594+
595+
logger.info("Loading remote tasks...")
596+
api.load_remote_data()
597+
598+
# Find the specified task list
599+
target_task_list = None
600+
for task_list in api.task_lists:
601+
if task_list.uid == list_uid:
602+
target_task_list = task_list
603+
break
604+
605+
if not target_task_list:
606+
click.echo(f"Error: Task list with UID '{list_uid}' not found.", err=True)
607+
raise click.Abort()
608+
609+
click.echo(
610+
f"# Dumping all tasks from list: '{target_task_list.name}' (UID: {list_uid})"
611+
)
612+
click.echo(f"# Total tasks: {len(target_task_list.tasks)}")
613+
click.echo("")
614+
615+
if not target_task_list.tasks:
616+
click.echo("# No tasks found in this list.")
617+
return
618+
619+
# Print each task's VTODO format
620+
for i, task in enumerate(target_task_list.tasks, 1):
621+
click.echo(f"# Task {i}/{len(target_task_list.tasks)}: {task.text}")
622+
click.echo(f"# UID: {task.uid}")
623+
click.echo("")
624+
vtodo_string = task.to_ical()
625+
click.echo(vtodo_string)
626+
click.echo("") # Extra blank line between tasks
627+
628+
if debug:
629+
click.echo(
630+
"Debug mode: Starting interactive console. API and task list available as 'api', 'target_task_list'."
631+
)
632+
_globals = globals().copy()
633+
_locals = locals().copy()
634+
_globals.update(_locals)
635+
code.interact(local=_globals)
636+
637+
except click.UsageError as ue:
638+
click.echo(f"Configuration error: {ue}", err=True)
639+
raise click.Abort()
640+
except ConnectionError as ce:
641+
click.echo(f"Connection failed: {ce}", err=True)
642+
raise click.Abort()
643+
except Exception as e:
644+
logger.exception(f"An unexpected error occurred: {e}")
645+
click.echo(f"Error: {e}", err=True)
646+
raise click.Abort()
647+
648+
547649
if __name__ == "__main__":
548650
cli()

caldav_tasks_api/caldav_tasks_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
class TasksAPI:
1919

20-
VERSION: str = "1.2.4"
20+
VERSION: str = "1.3.0"
2121

2222
def __init__(
2323
self,

caldav_tasks_api/utils/logging_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def setup_logging():
1212

1313
# Console logger
1414
# Determine console log level from environment variable, default to INFO
15-
console_log_level = os.environ.get("CALDAV_TASKS_API_LOG_LEVEL", "INFO").upper()
15+
console_log_level = os.environ.get("CALDAV_TASKS_API_LOG_LEVEL", "WARNING").upper()
1616
try:
1717
logger.add(
1818
sys.stderr,
@@ -23,14 +23,14 @@ def setup_logging():
2323
except ValueError: # Handle invalid log level from env var
2424
logger.add(
2525
sys.stderr,
26-
level="INFO", # Default to INFO if env var is invalid
26+
level="WARNING", # Default to INFO if env var is invalid
2727
format="<green>{time:YYYY-MM-DD HH:mm:ss}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>",
2828
colorize=True,
2929
)
3030
logger.warning(
3131
f"Invalid CALDAV_TASKS_API_LOG_LEVEL '{console_log_level}'. Defaulting to INFO for console."
3232
)
33-
console_log_level = "INFO" # Update for the info message below
33+
console_log_level = "WARNING" # Update for the info message below
3434

3535
# File logger
3636
# Using appname and appauthor (you might want to centralize these, e.g., from setup.py or a config)

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
project = "Caldav-Tasks-API"
2626
copyright = "2025, thiswillbeyourgithub"
2727
author = "thiswillbeyourgithub"
28-
release = "1.2.4"
28+
release = "1.3.0"
2929

3030
# -- General configuration ---------------------------------------------------
3131
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

docs/source/the_tests.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Test Coverage Summary
2020
| TasksAPI | Create and rename/update task | `test_create_and_rename_task` ||
2121
| TasksAPI | `TaskData.to_dict()` conversion | `test_task_to_dict` ||
2222
| CLI | `show-summary --json` command runs successfully | `test_cli_show_summary_json_runs_successfully` ||
23+
| CLI | `dump-all-tasks` command runs successfully | `test_cli_dump_all_tasks_runs_successfully` ||
2324
| TasksAPI | Add task attempt fails (read-only mode) | `test_add_task_in_read_only_mode` ||
2425
| TasksAPI | Delete task attempt fails (read-only mode) | `test_delete_task_in_read_only_mode` ||
2526
| TasksAPI | Update task attempt fails (read-only mode) | `test_update_task_in_read_only_mode` ||

docs/source/the_usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ caldav-tasks-api list-lists > all_lists.json
7676
- `--username TEXT`: CalDAV username (or set `CALDAV_TASKS_API_USERNAME` env var)
7777
- `--password TEXT`: CalDAV password (or set `CALDAV_TASKS_API_PASSWORD` env var)
7878
- `--nextcloud-mode` / `--no-nextcloud-mode`: Adjust URL for Nextcloud (default: True)
79-
- `--debug` / `--no-debug`: Enable interactive debugging console (default: False)
79+
- `--debug` / `--no-debug`: Enable interactive debugging console (default: False). Also changes the log level, which by default is `WARNING` (or set `CALDAV_TASKS_API_LOG_LEVEL`)
8080

8181
### Specific command options:
8282

0 commit comments

Comments
 (0)