aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.mod2
-rw-r--r--go.sum2
-rw-r--r--gsp.111
-rw-r--r--main.go14
4 files changed, 26 insertions, 3 deletions
diff --git a/go.mod b/go.mod
index 5a7aafb..fe1bcba 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,5 @@
module git.thomasvoss.com/gsp
go 1.21.0
+
+require git.thomasvoss.com/getgopt v1.0.1
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..9bd5a3b
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,2 @@
+git.thomasvoss.com/getgopt v1.0.1 h1:i2eyNe0K0MEEwsVpCFVVNKqV//WpEv54wWPyY6yKU7s=
+git.thomasvoss.com/getgopt v1.0.1/go.mod h1:xGRkf4eAWU0vXcnddTN5d6MB5dbca8+G1qM2PWSmZbg=
diff --git a/gsp.1 b/gsp.1
index 761dd51..82bb9f4 100644
--- a/gsp.1
+++ b/gsp.1
@@ -6,6 +6,7 @@
.Nd better syntax for HTML and XML
.Sh SYNOPSIS
.Nm
+.Op Fl x
.Op Ar
.Sh DESCRIPTION
.Nm
@@ -23,9 +24,17 @@ form of
.Ql <tag>
as opposed to XML where they take the form of
.Ql <tag/> .
-If the document begins with an XML document type, then
+If the document begins with an XML document type or the
+.Fl x
+flag is specified, then
.Nm
will transpile to XML.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl x
+Transpile to XML instead of HTML.
+.El
.Sh EXIT STATUS
.Ex -std gsp
.Sh EXAMPLES
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)
}
}