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.Printf("%+v\n", links) }