From 6ae1c16ec74dfef44dad2b49fc19bef4ee945ec4 Mon Sep 17 00:00:00 2001 From: demo Date: Fri, 8 May 2026 10:37:02 -0400 Subject: feat: implement localclient logic I've also added the local html files I'll be working with. --- cmd/localclient/main.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'cmd/localclient/main.go') diff --git a/cmd/localclient/main.go b/cmd/localclient/main.go index 21d405d..e65e49f 100644 --- a/cmd/localclient/main.go +++ b/cmd/localclient/main.go @@ -2,13 +2,44 @@ package main import ( "flag" + "fmt" "log" + "os" + "strings" + + "git.brandonirizarry.xyz/links/internal/findlinks" ) func main() { + // Set up logging. + log.SetFlags(log.LstdFlags | log.Lshortfile) + + // Retrieve the CLI flags, and check them. filename := flag.String("file", "", "Local HTML file") + flag.Parse() + if *filename == "" { log.Fatal("Missing -file argument") } + // FIXME: .htm is possible as well, but I'm skipping that for + // now. Also, we could look into templates and that sort of + // thing at some point. + if !strings.HasSuffix(*filename, ".html") { + log.Fatal("Need HTML file (.html)") + } + + // Open the local file. + f, err := os.Open(*filename) + if err != nil { + log.Fatalf("can't open %s: %v", *filename, err) + } + defer f.Close() + + links, err := findlinks.FindLinks(f) + if err != nil { + log.Fatal(err) + } + + fmt.Println(links) } -- cgit v1.2.3