diff options
| author | dacctal <dacctalyt@gmail.com> | 2026-04-14 19:31:34 +0000 |
|---|---|---|
| committer | dacctal <dacctalyt@gmail.com> | 2026-04-14 19:31:34 +0000 |
| commit | 2f10c2daea01738465c45f95162c0d56ddbea643 (patch) | |
| tree | 91b4cef5f7281dbf824f89853b24a8b50e54bf81 | |
| parent | c19258a3e31aabc1a0aca42cbf3d6af2eee61c8f (diff) | |
| -rwxr-xr-x | bldit | 2 | ||||
| -rw-r--r-- | is_lines.v | 9 | ||||
| -rw-r--r-- | main.v | 11 |
3 files changed, 21 insertions, 1 deletions
@@ -0,0 +1,2 @@ +#!/usr/bin/env sh +v . -o prile diff --git a/is_lines.v b/is_lines.v new file mode 100644 index 0000000..d387063 --- /dev/null +++ b/is_lines.v @@ -0,0 +1,9 @@ +module is_lines + +fn is_lines(args []string) { + for arg in args[1..] { + if arg == "-n" { + return true + } + } +} @@ -1,12 +1,21 @@ import os +import is_lines + fn main() { if os.args.len <= 1 { println("usage: prile [filename]...") exit(1) } + + mut lines := is_lines(os.args) + for arg in os.args[1..] { if !os.is_file(arg) { continue } - println(os.read_file(arg) or {""}) + content := os.read_file(arg) or {""} + for i, line in content.split('\n') { + if lines { println('${i+1:3} | ${line)}' } + else { println(line) } + } } } |
