Browse Source

fix #2157

Embed a copy of the ergo default config in the binary;
add `ergo defaultconfig` to print it to stdout
tags/v2.14.0-rc1
Shivaram Lingamneni 1 month ago
parent
commit
af521c844f
1 changed files with 7 additions and 0 deletions
  1. 7
    0
      ergo.go

+ 7
- 0
ergo.go View File

@@ -7,6 +7,7 @@ package main
7 7
 
8 8
 import (
9 9
 	"bufio"
10
+	_ "embed"
10 11
 	"fmt"
11 12
 	"log"
12 13
 	"os"
@@ -26,6 +27,9 @@ import (
26 27
 var commit = ""  // git hash
27 28
 var version = "" // tagged version
28 29
 
30
+//go:embed default.yaml
31
+var defaultConfig string
32
+
29 33
 // get a password from stdin from the user
30 34
 func getPasswordFromTerminal() string {
31 35
 	bytePassword, err := term.ReadPassword(int(syscall.Stdin))
@@ -94,6 +98,7 @@ Usage:
94 98
 	ergo importdb <database.json> [--conf <filename>] [--quiet]
95 99
 	ergo genpasswd [--conf <filename>] [--quiet]
96 100
 	ergo mkcerts [--conf <filename>] [--quiet]
101
+	ergo defaultconfig
97 102
 	ergo run [--conf <filename>] [--quiet] [--smoke]
98 103
 	ergo -h | --help
99 104
 	ergo --version
@@ -173,6 +178,8 @@ Options:
173 178
 		if err != nil {
174 179
 			log.Fatal("Error while importing db:", err.Error())
175 180
 		}
181
+	} else if arguments["defaultconfig"].(bool) {
182
+		fmt.Print(defaultConfig)
176 183
 	} else if arguments["run"].(bool) {
177 184
 		if !arguments["--quiet"].(bool) {
178 185
 			logman.Info("server", fmt.Sprintf("%s starting", irc.Ver))

Loading…
Cancel
Save