From 296d89ca56d70638aa51b272a46dfe389fe126c9 Mon Sep 17 00:00:00 2001 From: Juhani Krekelä Date: Sun, 16 Feb 2025 01:55:25 +0200 Subject: Support relative paths as arguments Previously if you wanted to add a local file into the watch_later entries, you needed to pass the absolute path to it to later(1). Make later(1) transform a local path into an absolute path as needed. --- src/later/cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/later/cli.py b/src/later/cli.py index ece41ce..6c369be 100644 --- a/src/later/cli.py +++ b/src/later/cli.py @@ -1,4 +1,5 @@ import getopt +import os import sys from dataclasses import dataclass, field from typing import Protocol @@ -42,12 +43,19 @@ class Arguments: def add_entries(args, entries): for entry in args.rest: + # A watch_later entry for a file must be based on its absolute path. + if os.path.isfile(entry): + entry = os.path.abspath(entry) entries.add(entry) def delete_entries(args, entries): for entry in args.rest: entries.delete(entry) + # Also handle cases where we were given a local path. + # It's always safe to call this, since .delete() ignores non-existent + # entries. + entries.delete(os.path.abspath(entry)) def list_entries(args, entries): -- cgit v1.2.3-2-gb3c3