From f53a219e98b7cf0d5b84a3272d6902c1ef5ecb37 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Sat, 18 Jun 2022 19:12:11 -0400 Subject: [PATCH] Add command line flag for processing root --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 0906fd9..3973fce 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "golang.org/x/net/html" "golang.org/x/net/html/atom" @@ -11,6 +12,13 @@ import ( "strings" ) +var start string + +func init() { + flag.StringVar(&start, "root", ".", "directory containing html files") + flag.Parse() +} + func fixNode(s fs.FS, n *html.Node, fixed *bool) { if n.Type != html.ElementNode || n.DataAtom != atom.A { goto recurse @@ -48,7 +56,6 @@ recurse: } func main() { - start := "." here := os.DirFS(start) err := fs.WalkDir(here, ".", func(p string, d fs.DirEntry, err error) error { -- 2.45.2