gtx


Branch: develop

Author
thewhodidthis <thewhodidthis@fastmail.com>
Date
Feb. 19 '23 14:52:09
Commit
fb951f95f91d2558187e5e8d112b9478f3071455
Parent
aa359907f1b0bf7be8a69873cb700b7e56a083f6
Changes
diff --git a/options.go b/options.go
deleted file mode 100644
index 5a86d42..0000000
--- a/options.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package main
-
-import (
-	"encoding/json"
-	"fmt"
-	"os"
-	"path/filepath"
-)
-
-type options struct {
-	Branches manyflag `json:"branches"`
-	config   string
-	Export   bool   `json:"export"`
-	Force    bool   `json:"force"`
-	Name     string `json:"name"`
-	Quiet    bool   `json:"quiet"`
-	Source   string `json:"source"`
-	Template string `json:"template"`
-}
-
-// Helps store options as JSON.
-func (o *options) save(p string) error {
-	bs, err := json.MarshalIndent(o, "", "  ")
-
-	if err != nil {
-		return fmt.Errorf("unable to encode config file: %v", err)
-	}
-
-	if err := os.WriteFile(filepath.Join(p, o.config), bs, 0644); err != nil {
-		return fmt.Errorf("unable to save config file: %v", err)
-	}
-
-	return nil
-}
diff --git a/types.go b/types.go
index 27d014b..723dd12 100644
--- a/types.go
+++ b/types.go
@@ -1,6 +1,9 @@
 package main
 
 import (
+	"encoding/json"
+	"fmt"
+	"os"
 	"path/filepath"
 	"strings"
 	"time"
@@ -99,3 +102,29 @@ func (f *manyflag) Set(value string) error {
 func (f *manyflag) String() string {
 	return strings.Join(*f, ", ")
 }
+
+type options struct {
+	Branches manyflag `json:"branches"`
+	config   string
+	Export   bool   `json:"export"`
+	Force    bool   `json:"force"`
+	Name     string `json:"name"`
+	Quiet    bool   `json:"quiet"`
+	Source   string `json:"source"`
+	Template string `json:"template"`
+}
+
+// Helps store options as JSON.
+func (o *options) save(p string) error {
+	bs, err := json.MarshalIndent(o, "", "  ")
+
+	if err != nil {
+		return fmt.Errorf("failed to encode options: %v", err)
+	}
+
+	if err := os.WriteFile(filepath.Join(p, o.config), bs, 0644); err != nil {
+		return fmt.Errorf("failed to write options: %v", err)
+	}
+
+	return nil
+}