Changed GoConfig to UsrConfig
Changed GoConfig struct to UsrConfig
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func backUp(cmd string, c GoConfig) {
|
||||
func backUp(cmd string, c UsrConfig) {
|
||||
switch cmd {
|
||||
case "full":
|
||||
fmt.Println("Starting full server backup")
|
||||
|
||||
4
cli.go
4
cli.go
@@ -19,9 +19,7 @@ func cliToolMode() {
|
||||
startStopServer("stop", c)
|
||||
}
|
||||
case "help", "h", "--help", "-h":
|
||||
fmt.Printf("Start Server: %s start\nStop Server: %s stop\n", os.Args[0], os.Args[0])
|
||||
fmt.Printf("Run backup\n\tFull backup: %s backup full", os.Args[0])
|
||||
fmt.Printf("\n\tBackup saves: %s backup saves\n", os.Args[0])
|
||||
fmt.Printf("Start Server: %s start\nStop Server: %s stop\nRun backup\n\tFull backup: %s backup full\n\tBackup saves: %s backup saves\n", os.Args[0], os.Args[0], os.Args[0], os.Args[0])
|
||||
case "download":
|
||||
if len(os.Args) > 2 {
|
||||
switch os.Args[2] {
|
||||
|
||||
@@ -9,14 +9,14 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func readCfg(factCfg string) GoConfig {
|
||||
func readCfg(factCfg string) UsrConfig {
|
||||
//read config file (YAML)
|
||||
fileBytes, err := os.ReadFile(factCfg)
|
||||
if err != nil {
|
||||
log.Fatalf("Error reading config file: %v", err)
|
||||
}
|
||||
// return Struct
|
||||
var config GoConfig
|
||||
var config UsrConfig
|
||||
err = yaml.Unmarshal(fileBytes, &config)
|
||||
if err != nil {
|
||||
log.Fatalf("Error unmarshalling YAML file: %v", err)
|
||||
@@ -32,7 +32,7 @@ func isItReal(path string) bool { //check if path exists
|
||||
return false
|
||||
}
|
||||
}
|
||||
func verifyConfig(config GoConfig) bool { // check each file/dir to see if it exists
|
||||
func verifyConfig(config UsrConfig) bool { // check each file/dir to see if it exists
|
||||
if !isItReal(config.Server.ServDir) { //check for Server directory
|
||||
fmt.Printf("PATH NOT FOUND: %s", config.Server.ServDir)
|
||||
return false
|
||||
|
||||
BIN
factoryman
BIN
factoryman
Binary file not shown.
@@ -7,7 +7,7 @@ import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func startStopServer(cmd string, con GoConfig) {
|
||||
func startStopServer(cmd string, con UsrConfig) {
|
||||
switch cmd {
|
||||
case "start":
|
||||
x := fmt.Sprintf("%s --port %d --server-settings %s --start-server %s", con.Server.ServExec, con.Server.ServPort, con.Server.ServCfg, con.Server.WorldFile)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
// config struct
|
||||
type GoConfig struct {
|
||||
type UsrConfig struct {
|
||||
Server struct { // server specific settings
|
||||
ServDir string `yaml:"serverFolder"`
|
||||
WorldFile string `yaml:"worldFile"`
|
||||
|
||||
Reference in New Issue
Block a user