From c7a34a7d9391fcdd229209e65533858446eb832d Mon Sep 17 00:00:00 2001 From: raul Date: Tue, 14 May 2024 16:31:36 +0200 Subject: [PATCH] Add option to render client UI in pure ASCII --- README.md | 1 + cmd/client.go | 5 +++++ cmd/clientFunc.go | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/README.md b/README.md index a4086da..b7d6f61 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Usage: mini-chat client [flags] Flags: + -a, --ascii Render UI in pure ASCII, might help with rendering issues -h, --help help for client --insecure [UNSAFE] Do not use TLS encryption -i, --ip string Server IP to connect to diff --git a/cmd/client.go b/cmd/client.go index 78a63f3..cf8507d 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -37,6 +37,7 @@ func init() { clientCmd.PersistentFlags().StringP("ip", "i", "", "Server IP to connect to") clientCmd.PersistentFlags().StringP("port", "p", "1302", "Server port to connect to") clientCmd.Flags().Bool("insecure", false, "[UNSAFE] Do not use TLS encryption") + clientCmd.Flags().BoolP("ascii", "a", false, "Render UI in pure ASCII, might help with rendering issues") } func setClientParameters(cmd *cobra.Command) error { @@ -63,5 +64,9 @@ func setClientParameters(cmd *cobra.Command) error { clientInsecure = true } + ascii, err := cmd.Flags().GetBool("ascii") + if ascii == true { + useASCII = true + } return nil } diff --git a/cmd/clientFunc.go b/cmd/clientFunc.go index b1b6518..2f6090b 100644 --- a/cmd/clientFunc.go +++ b/cmd/clientFunc.go @@ -41,6 +41,7 @@ var ( serverIP string data Message clientInsecure bool + useASCII bool ) func startSecureConnection() (net.Conn, error) { @@ -185,6 +186,9 @@ func GUI() { g.SetManagerFunc(layout) g.Mouse = true g.Cursor = true + if useASCII == true { + g.ASCII = true + } initKeybindings(g) go listenMessages(g)