aboutsummaryrefslogtreecommitdiff
path: root/src/gistatic.go
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-05-02 18:34:58 -0300
committerEuAndreh <eu@euandre.org>2025-05-02 19:10:40 -0300
commit715815e3bea7fec41a385742b0a6a8fee4c5cf99 (patch)
treee752e49b0127cae36724877174579aaff801a0c5 /src/gistatic.go
parentWIP: Commit sh code as-is (diff)
downloadgistatic-715815e3bea7fec41a385742b0a6a8fee4c5cf99.tar.gz
gistatic-715815e3bea7fec41a385742b0a6a8fee4c5cf99.tar.xz
Switch from POSIX sh to Go
Diffstat (limited to 'src/gistatic.go')
-rw-r--r--src/gistatic.go79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/gistatic.go b/src/gistatic.go
new file mode 100644
index 0000000..b4ad501
--- /dev/null
+++ b/src/gistatic.go
@@ -0,0 +1,79 @@
+package gistatic
+
+import (
+ "flag"
+ "fmt"
+ "io"
+ "os"
+
+ g "gobang"
+)
+
+
+
+type argsT struct{
+ outputPath string
+ cloneUrl string
+ allArgs []string
+}
+
+
+func usage(argv0 string, w io.Writer) {
+ fmt.Fprintf(
+ w,
+ "Usage: %s [-o DIRECTORY] [-u CLONE_URL] REPOSITORY",
+ argv0,
+ )
+}
+
+func getopt(allArgs []string, w io.Writer) (argsT, int) {
+ argv0 := allArgs[0]
+ argv := allArgs[1:]
+ fs := flag.NewFlagSet("", flag.ContinueOnError)
+ fs.Usage = func() {}
+ fs.SetOutput(w)
+ outputPath := fs.String(
+ "o",
+ g.Must(os.Getwd()),
+ "The directory where to write the generated files",
+ )
+ cloneUrl := fs.String(
+ "u",
+ "",
+ "The prefix of the online cloning addresss",
+ )
+ if fs.Parse(argv) != nil {
+ usage(argv0, w)
+ return argsT{}, 2
+ }
+
+ subArgs := fs.Args()
+ if len(subArgs) == 0 {
+ fmt.Fprintf(w, "Missing DIRECTORY.\n")
+ usage(argv0, w)
+ return argsT{}, 2
+ }
+
+ args := argsT{
+ outputPath: *outputPath,
+ cloneUrl: *cloneUrl,
+ allArgs: allArgs,
+ }
+
+ return args, 0
+}
+
+func run(args argsT, stdin io.Reader, stdout io.Writer, stderr io.Writer) int {
+ return 0
+}
+
+
+
+func Main() {
+ g.Init()
+ args, rc := getopt(os.Args, os.Stderr)
+ if rc != 0 {
+ os.Exit(rc)
+ }
+ os.Exit(run(args, os.Stdin, os.Stdout, os.Stderr))
+}