diff options
| author | demo <demo@antix1> | 2026-05-08 10:37:02 -0400 |
|---|---|---|
| committer | demo <demo@antix1> | 2026-05-08 10:37:02 -0400 |
| commit | 6ae1c16ec74dfef44dad2b49fc19bef4ee945ec4 (patch) | |
| tree | 2021dbddecc67941dca4da5e643175fd3c689355 /cmd | |
| parent | 8a3554d4f32d631bd1c7cc6254ab11b14b541c67 (diff) | |
feat: implement localclient logic
I've also added the local html files I'll be working with.
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/localclient/main.go | 31 |
1 files changed, 31 insertions, 0 deletions
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) } |
