aboutsummaryrefslogtreecommitdiff
path: root/api/paths.yaml
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-15 18:13:44 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-15 18:14:09 -0500
commit290c72732f21f1cddb3a0f8ec3213e4ec321da14 (patch)
tree7c6c939a8d563edda5afddefcc2810d550ede0f3 /api/paths.yaml
parenta1884f7a85cbee5a67cf48c9e7b088fdea8b8b38 (diff)
Add Path.lines()
Diffstat (limited to 'api/paths.yaml')
-rw-r--r--api/paths.yaml25
1 files changed, 21 insertions, 4 deletions
diff --git a/api/paths.yaml b/api/paths.yaml
index 532d9c71..8fbd18dc 100644
--- a/api/paths.yaml
+++ b/api/paths.yaml
@@ -107,14 +107,31 @@ Path.by_line:
example: |
# Safely handle file not being readable:
if lines := (./file.txt).by_line()
- for line in lines
- say(line.upper())
+ for line in lines
+ say(line.upper())
else
- say("Couldn't read file!")
+ say("Couldn't read file!")
# Assume the file is readable and error if that's not the case:
for line in (/dev/stdin).by_line()!
- say(line.upper())
+ say(line.upper())
+
+Path.lines:
+ short: return the lines in a file
+ description: >
+ Returns a list with the lines of text in a file or returns none if the file
+ could not be opened.
+ return:
+ type: '[Text]?'
+ description: >
+ A list of the lines in a file or none if the file couldn't be read.
+ args:
+ path:
+ type: 'Path'
+ description: >
+ The path of the file.
+ example: |
+ lines := (./file.txt).lines()!
Path.can_execute:
short: check execute permissions