From 271017ba9970e4220e1bd0dc83ce146afe9222a2 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 24 Jun 2025 13:37:09 -0400 Subject: Add Path.has_extension() and update manpages/api docs --- api/paths.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'api/paths.yaml') diff --git a/api/paths.yaml b/api/paths.yaml index 40813129..1bfe5d6d 100644 --- a/api/paths.yaml +++ b/api/paths.yaml @@ -463,6 +463,34 @@ Path.group: = "root" >> (/non/existent/file).group() = none + +Path.has_extension: + short: check if a path has a given extension + description: > + Return whether or not a path has a given file extension. + return: + type: 'Bool' + description: > + Whether or not the path has the given extension. + args: + path: + type: 'Path' + description: > + A path. + extension: + type: 'Text' + description: > + A file extension (leading `.` is optional). If empty, the check will + test if the file does not have any file extension. + example: | + >> (/foo.txt).has_extension("txt") + = yes + >> (/foo.txt).has_extension(".txt") + = yes + >> (/foo.tar.gz).has_extension("gz") + = yes + >> (/foo.tar.gz).has_extension("zip") + = no Path.is_directory: short: check if a path is a directory -- cgit v1.2.3