From 5a63f7620cb579e8632ec8847ec2e0a4e9047213 Mon Sep 17 00:00:00 2001
From: Xavier Perret <xa.perret@outlook.com>
Date: Sat, 29 Oct 2022 16:10:12 +0200
Subject: [PATCH] improved clients

---
 app/client.go | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/app/client.go b/app/client.go
index 0a959d3..639ac7b 100644
--- a/app/client.go
+++ b/app/client.go
@@ -1,7 +1,12 @@
 package main
 
 import (
+	"fmt"
+	"gopkg.in/yaml.v3"
+	command_line "node/command-line"
 	. "node/types"
+	"node/utilities"
+	"os"
 )
 
 /*
@@ -12,5 +17,33 @@ import (
  */
 
 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)
 
 }
-- 
GitLab