From 7eac3c24255a86257d42ab38668cbd88dc96f55b Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 10 Sep 2023 19:47:52 +0200 Subject: Add the ‘-x’ command-line option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 8351b78..c805fec 100644 --- a/main.go +++ b/main.go @@ -4,16 +4,26 @@ import ( "fmt" "os" + "git.thomasvoss.com/getgopt" "git.thomasvoss.com/gsp/formatter" "git.thomasvoss.com/gsp/parser" ) func main() { - if len(os.Args) == 1 { + for opt := byte(0); getgopt.Getopt(len(os.Args), os.Args, "x", &opt); { + switch opt { + case 'x': + parser.Xml = true + } + } + + os.Args = os.Args[getgopt.Optind:] + + if len(os.Args) == 0 { process("-") } - for _, arg := range os.Args[1:] { + for _, arg := range os.Args { process(arg) } } -- cgit v1.2.3