aboutsummaryrefslogtreecommitdiff
path: root/man/man3
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-26 21:13:04 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-26 21:13:04 -0500
commit35053e65b946264715aca2b348ee25313b55d2f6 (patch)
tree9219c626f8a277dd1c7d1240079f08a06d4b8073 /man/man3
parent3ad07260f369dc285e5ae856b78a58c3b13ee622 (diff)
Add missing manpages
Diffstat (limited to 'man/man3')
-rw-r--r--man/man3/tomo-Path.lines.333
-rw-r--r--man/man3/tomo-Text.find.338
-rw-r--r--man/man3/tomo-at_cleanup.338
3 files changed, 109 insertions, 0 deletions
diff --git a/man/man3/tomo-Path.lines.3 b/man/man3/tomo-Path.lines.3
new file mode 100644
index 00000000..e4e95e7e
--- /dev/null
+++ b/man/man3/tomo-Path.lines.3
@@ -0,0 +1,33 @@
+'\" t
+.\" Copyright (c) 2025 Bruce Hill
+.\" All rights reserved.
+.\"
+.TH Path.lines 3 2025-11-23 "Tomo man-pages"
+.SH NAME
+Path.lines \- return the lines in a file
+.SH LIBRARY
+Tomo Standard Library
+.SH SYNOPSIS
+.nf
+.BI Path.lines\ :\ func(path:\ Path\ ->\ [Text]?)
+.fi
+.SH DESCRIPTION
+Returns a list with the lines of text in a file or returns none if the file could not be opened.
+
+
+.SH ARGUMENTS
+
+.TS
+allbox;
+lb lb lbx lb
+l l l l.
+Name Type Description Default
+path Path The path of the file. -
+.TE
+.SH RETURN
+A list of the lines in a file or none if the file couldn't be read.
+
+.SH EXAMPLES
+.EX
+lines := (./file.txt).lines()!
+.EE
diff --git a/man/man3/tomo-Text.find.3 b/man/man3/tomo-Text.find.3
new file mode 100644
index 00000000..17d78a0a
--- /dev/null
+++ b/man/man3/tomo-Text.find.3
@@ -0,0 +1,38 @@
+'\" t
+.\" Copyright (c) 2025 Bruce Hill
+.\" All rights reserved.
+.\"
+.TH Text.find 3 2025-11-23 "Tomo man-pages"
+.SH NAME
+Text.find \- find a substring
+.SH LIBRARY
+Tomo Standard Library
+.SH SYNOPSIS
+.nf
+.BI Text.find\ :\ func(text:\ Text,\ target:\ Text,\ start:\ Int\ =\ 1\ ->\ Int)
+.fi
+.SH DESCRIPTION
+Find a substring within a text and return its index, if found.
+
+
+.SH ARGUMENTS
+
+.TS
+allbox;
+lb lb lbx lb
+l l l l.
+Name Type Description Default
+text Text The text to be searched. -
+target Text The target text to find. -
+start Int The index at which to begin searching. 1
+.TE
+.SH RETURN
+The index where the first occurrence of `target` appears, or `none` if it is not found.
+
+.SH EXAMPLES
+.EX
+assert "one two".find("one") == 1
+assert "one two".find("two") == 5
+assert "one two".find("three") == none
+assert "one two".find("o", start=2) == 7
+.EE
diff --git a/man/man3/tomo-at_cleanup.3 b/man/man3/tomo-at_cleanup.3
new file mode 100644
index 00000000..a8dc04ed
--- /dev/null
+++ b/man/man3/tomo-at_cleanup.3
@@ -0,0 +1,38 @@
+'\" t
+.\" Copyright (c) 2025 Bruce Hill
+.\" All rights reserved.
+.\"
+.TH at_cleanup 3 2025-11-23 "Tomo man-pages"
+.SH NAME
+at_cleanup \- register a cleanup function
+.SH LIBRARY
+Tomo Standard Library
+.SH SYNOPSIS
+.nf
+.BI at_cleanup\ :\ func(fn:\ func()\ ->\ Void)
+.fi
+.SH DESCRIPTION
+Register a function that runs at cleanup time for Tomo programs. Cleanup time happens when a program exits (see `atexit()` in C), or immediately before printing error messages in a call to `fail()`. This allows for terminal cleanup so error messages can be visible as the program shuts down.
+
+
+.SH ARGUMENTS
+
+.TS
+allbox;
+lb lb lbx lb
+l l l l.
+Name Type Description Default
+fn func() A function to run at cleanup time. -
+.TE
+.SH RETURN
+Nothing.
+
+.SH NOTES
+Use this API very carefully, because errors that occur during cleanup functions may make it extremely hard to figure out what's going on. Cleanup functions should be designed to not error under any circumstances.
+
+.SH EXAMPLES
+.EX
+at_cleanup(func()
+ (/tmp/file.txt).remove(ignore_missing=yes)
+)
+.EE