From 8033dfea85db8e97f1546a9117edd8ad7710febe Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 10 May 2023 09:58:59 +0200 Subject: [PATCH] wip: naive datasheet file gathering --- gshmm.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gshmm.go b/gshmm.go index 53473ab..637f8ad 100644 --- a/gshmm.go +++ b/gshmm.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "os" + "path/filepath" "strings" "github.com/charmbracelet/bubbles/textinput" @@ -44,8 +45,20 @@ func initialModel() model { input := textinput.New() input.Focus() - // TODO(d1): gather actual datasheets - ds := []string{"foo", "bar", "baz", "bing"} + var ds []string + // TODO(d1): handle error in interface? + _ = filepath.Walk(".", func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + name := info.Name() + if strings.HasSuffix(name, "pdf") { + ds = append(ds, name) + } + + return nil + }) return model{ filterInput: input,