aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-15 14:22:11 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-15 14:22:11 -0400
commitf51acef40e8297d7bd41b774413aa8331ca946ed (patch)
tree56aa02541d60beb3ece496fed2c11afd3ae942f3 /examples
parent7a2653501310825e02d99d51fb4b9f1aacc75214 (diff)
Overhaul of Path so it uses root and array of components instead of
stringly typed
Diffstat (limited to 'examples')
-rw-r--r--examples/ini/ini.tm2
-rw-r--r--examples/tomo-install/tomo-install.tm2
-rw-r--r--examples/tomodeps/tomodeps.tm6
-rw-r--r--examples/wrap/wrap.tm2
4 files changed, 6 insertions, 6 deletions
diff --git a/examples/ini/ini.tm b/examples/ini/ini.tm
index 9b27e8cb..1c50ac37 100644
--- a/examples/ini/ini.tm
+++ b/examples/ini/ini.tm
@@ -7,7 +7,7 @@ _HELP := "
"
func parse_ini(path:Path -> {Text,{Text,Text}}):
- text := path:read() or exit("Could not read INI file: $\[31;1]$(path.text)$\[]")
+ text := path:read() or exit("Could not read INI file: $\[31;1]$(path)$\[]")
sections := @{:Text,@{Text,Text}}
current_section := @{:Text,Text}
diff --git a/examples/tomo-install/tomo-install.tm b/examples/tomo-install/tomo-install.tm
index f769204f..43e23028 100644
--- a/examples/tomo-install/tomo-install.tm
+++ b/examples/tomo-install/tomo-install.tm
@@ -13,7 +13,7 @@ func find_urls(path:Path -> [Text]):
if path:is_directory():
for f in path:children():
urls:insert_all(find_urls(f))
- else if path:is_file() and path:ends_with(".tm"):
+ else if path:is_file() and path:extension() == ".tm":
for line in path:by_line()!:
if m := line:matches($/use{space}{url}/) or line:matches($/{id}{space}:={space}use{space}{url}/):
urls:insert(m[-1])
diff --git a/examples/tomodeps/tomodeps.tm b/examples/tomodeps/tomodeps.tm
index 93e3eb42..279e5051 100644
--- a/examples/tomodeps/tomodeps.tm
+++ b/examples/tomodeps/tomodeps.tm
@@ -36,7 +36,7 @@ func _build_dependency_graph(dep:Dependency, dependencies:@{Dependency,{Dependen
dir := (~/.local/share/tomo/installed/$module)
module_deps := @{:Dependency}
visited := @{:Path}
- unvisited := @{f:resolved() for f in dir:files() if f:ends_with(".tm")}
+ unvisited := @{f:resolved() for f in dir:files() if f:extension() == ".tm"}
while unvisited.length > 0:
file := unvisited.items[-1]
unvisited:remove(file)
@@ -66,9 +66,9 @@ func _printable_name(dep:Dependency -> Text):
is File(f):
f = f:relative()
if f:exists():
- return "$(f.text)"
+ return Text(f)
else:
- return "$(\x1b)[31;1m$(f.text) (not found)$(\x1b)[m"
+ return "$(\x1b)[31;1m$(f) (not found)$(\x1b)[m"
func _draw_tree(dep:Dependency, dependencies:{Dependency,{Dependency}}, already_printed:@{Dependency}, prefix="", is_last=yes):
if already_printed:has(dep):
diff --git a/examples/wrap/wrap.tm b/examples/wrap/wrap.tm
index 94d752bd..c90713a9 100644
--- a/examples/wrap/wrap.tm
+++ b/examples/wrap/wrap.tm
@@ -82,7 +82,7 @@ func main(files:[Path], width=80, inplace=no, min_split=3, rewrap=yes, hyphen=UN
files = [(/dev/stdin)]
for file in files:
- text := file:read() or exit("Could not read file: $(file.text)")
+ text := file:read() or exit("Could not read file: $file")
if rewrap:
text = unwrap(text)