Files
rexlang/examples/01_hello_tool.rex
Your NameandClaude Opus 5.5 7cf9727bcd Rename the language from Dino to Rex
Files use .rex, the command is rex, and the crate, runtime prefixes,
docs, editor files and examples all use the new name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:51:23 +01:00

30 lines
642 B
Rexx

// A small CLI tool: count lines and words in files.
import os
struct Stats {
lines: int
words: int
}
func count(path: string): (Stats, error) {
var text = os.read_file(path)? // ? returns the error to the caller
var stats = Stats{}
for line in text.lines() {
stats.lines += 1
stats.words += line.fields().len()
}
return stats, nil
}
func main() {
var args = os.args
for path in args[1..] {
var s, err = count(path)
if err != nil {
print("{path}: error: {err}")
continue
}
print("{path}: {s.lines} lines, {s.words} words")
}
}