Switched to using cobra for better cli support

This commit is contained in:
2026-05-31 17:04:39 -05:00
parent 2e00798d2d
commit 9b665d2df6
5 changed files with 49 additions and 16 deletions
+4 -7
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
"flag"
"io"
"log"
"net"
@@ -167,8 +166,6 @@ func TestMainHelperProcess(t *testing.T) {
if os.Getenv("GO_WANT_MAIN_HELPER") != "1" {
return
}
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
mode := os.Getenv("MAIN_HELPER_MODE")
switch mode {
case "success":
@@ -183,16 +180,16 @@ func TestMainHelperProcess(t *testing.T) {
_ = proc.Signal(os.Interrupt)
}
}()
os.Args = []string{"pastebin", "-config", cfgPath}
os.Args = []string{"pastebin", "--config", cfgPath}
main()
os.Exit(0)
case "bad-config":
os.Args = []string{"pastebin", "-config", "/no/such/config.yaml"}
os.Args = []string{"pastebin", "--config", "/no/such/config.yaml"}
main()
os.Exit(0)
case "storage-fail":
cfgPath := os.Getenv("MAIN_HELPER_CONFIG")
os.Args = []string{"pastebin", "-config", cfgPath}
os.Args = []string{"pastebin", "--config", cfgPath}
main()
os.Exit(0)
case "http-fail":
@@ -200,7 +197,7 @@ func TestMainHelperProcess(t *testing.T) {
if err := os.Chdir(t.TempDir()); err != nil {
os.Exit(2)
}
os.Args = []string{"pastebin", "-config", cfgPath}
os.Args = []string{"pastebin", "--config", cfgPath}
main()
os.Exit(0)
default: