diff options
| author | ewy <ewy0@protonmail.com> | 2026-04-29 00:47:34 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-04-29 00:47:34 +0200 |
| commit | 630d77e1962b43ee95e88a664f5e8b8993213060 (patch) | |
| tree | 8849c2a87443cd231786aed53b76dc7e4ea11aed /order | |
| parent | 8efcf029576ad82908b4ae80b2c92022dfb857d2 (diff) | |
big stuff
* send empty screen after tui confirmation
* add scroll view / viewport
* auto enable scroll view on short terminals
* add motd tips
* add subdirs as categories
* add inline toggle hotkey (i)
Diffstat (limited to 'order')
| -rw-r--r-- | order/order.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/order/order.go b/order/order.go new file mode 100644 index 0000000..40e6e73 --- /dev/null +++ b/order/order.go @@ -0,0 +1,50 @@ +package order + +import ( + "bufio" + "io" + "io/fs" + "os" + "pik/describe" + "pik/identity" + "strings" +) + +type Element struct { + Identifier identity.Identity + Description string +} + +type Order struct { + Elements []Element +} + +var Empty = Order{} + +func FromFile(f fs.FS, path string) (Order, error) { + fd, err := os.Open(path) + if err != nil { + return Empty, err + } + defer fd.Close() + return FromReader(fd) +} + +func FromReader(r io.Reader) (Order, error) { + scanner := bufio.NewScanner(r) + scanner.Split(bufio.ScanLines) + for scanner.Scan() { + line := scanner.Text() + line = strings.TrimSpace(line) + if line == "" { + continue + } + + for _, p := range describe.DescriptionPrefixes { + if strings.HasPrefix(line, p) { + continue + } + } + } + +} |
