Skip to content
Snippets Groups Projects
Commit 5a63f762 authored by Xavier Perret's avatar Xavier Perret
Browse files

improved clients

parent 8ebb6ef3
No related branches found
No related tags found
1 merge request!2added file to separate client function from the server
package main package main
import ( import (
"fmt"
"gopkg.in/yaml.v3"
command_line "node/command-line"
. "node/types" . "node/types"
"node/utilities"
"os"
) )
/* /*
...@@ -12,5 +17,33 @@ import ( ...@@ -12,5 +17,33 @@ import (
*/ */
func main() { func main() {
argsLen := len(os.Args)
isThereEnoughArgs := argsLen <= 1
if isThereEnoughArgs {
fmt.Println("First argument should be the path of the config file '--path=<config.yaml>'")
os.Exit(1)
}
// init configuration
args := os.Args[1:]
fmt.Println("Program started with arguments", args)
fmt.Println("config file path is ", args[0][7:])
buf, err := os.ReadFile(args[0][7:])
if err != nil {
fmt.Println("Error while reading the config file", err)
fmt.Println("Exiting...")
os.Exit(1)
}
var clientConfig Config
err = yaml.Unmarshal(buf, &clientConfig)
if err != nil {
os.Exit(1)
}
utilities.PrintConfig(clientConfig)
command_line.ClientUserInputLoop(clientConfig, true)
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment