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

Loading…
Cancel
Save