From 91f9c856cd5da86f086b66e77e781bbd12774f98 Mon Sep 17 00:00:00 2001 From: Banana Date: Thu, 28 Mar 2024 15:44:56 +0100 Subject: [PATCH] some changes and maybe use cobra in the future --- client/go-cli/Makefile | 25 +++++++++++++++------- client/go-cli/{README => README.md} | 32 ++++++++++++++++------------- client/go-cli/scientia-cli.go | 9 ++++++-- 3 files changed, 43 insertions(+), 23 deletions(-) rename client/go-cli/{README => README.md} (51%) diff --git a/client/go-cli/Makefile b/client/go-cli/Makefile index c1205f4..b8ab31a 100644 --- a/client/go-cli/Makefile +++ b/client/go-cli/Makefile @@ -1,17 +1,28 @@ all: - @echo "Options are: build and buildall" + @echo "Options are: build scientia-cli scientia-cli-linux-amd64 scientia-cli-windows-amd64 scientia-cli-darwin-amd64 clean buildall" -build: +scientia-cli: @echo "Building for local os/arch..." - go build -o scientia-cli-`go env GOOS`-`go env GOARCH` + go build -o scientia-cli -buildall: +scientia-cli-linux-amd64: @echo "Building for linux/amd64 arch..." GOOS=linux GOARCH=amd64 go build -o scientia-cli-linux-amd64 - @echo "Done: scientia-cli-linux-amd64" + +scientia-cli-windows-amd64: @echo "Building for windows/amd64 arch..." GOOS=windows GOARCH=amd64 go build -o scientia-cli-windows-amd64 - @echo "Done: scientia-cli-windows-amd64" + +scientia-cli-darwin-amd64: @echo "Building for macOS/amd64 arch..." GOOS=darwin GOARCH=amd64 go build -o scientia-cli-darwin-amd64 - @echo "Done: scientia-cli-darwin-amd64" \ No newline at end of file + +build: + @echo "Building for local os/arch..." + go build -o scientia-cli-`go env GOOS`-`go env GOARCH` + +buildall: scientia-cli-linux-amd64 scientia-cli-windows-amd64 scientia-cli-darwin-amd64 + @echo "Building for linux/amd64, windows/amd64 and macOS/amd64 arch..." + +clean: + rm -f scientia-cli scientia-cli-darwin-amd64 scientia-cli-windows-amd64 scientia-cli-linux-amd64 \ No newline at end of file diff --git a/client/go-cli/README b/client/go-cli/README.md similarity index 51% rename from client/go-cli/README rename to client/go-cli/README.md index a8b2fc3..04ff93f 100644 --- a/client/go-cli/README +++ b/client/go-cli/README.md @@ -1,28 +1,32 @@ +# scienta go cli client + This is a terminal cli client written in go to be used with scientia -https://://www.bananas-playground.net/projekt/scientia +https://://www.bananas-playground.net/projekt/scientia/ !WARNING! This is a very simple, with limited experience written, go program. Use at own risk and feel free to improve. # Howto build -Nothing special, just use the provide Makefile or directly "go build -o scientia-cli" to use your current os/arch settings. + +Nothing special, just use the provided Makefile or directly +"go build -o scientia-cli" to use your current os/arch settings. # Usage + At first usage you need to create the config and the individual secret. Run $scientia-cli -create-config-file to create the default config file. The path to the config file is printed. Change the host address and update your server it with the secret, which is randomly created. -Read from a file -$ scientia-cli file.txt -or piped -$ cat file.txt | scientia-cli - -Commandline arguments (optional): - -create-config-file - Create default config file - -debug - Print debug infos - -verbose - Produce verbose output +## Create + +Read from a file `$ scientia-cli file.txt` or piped `$ cat file.txt | scientia-cli` + +# Commandline arguments + +## Optinal + ++ `-create-config-file` Create default config file ++ `-debug` Print debug infos ++ `-verbose` Produce verbose output diff --git a/client/go-cli/scientia-cli.go b/client/go-cli/scientia-cli.go index 837bd78..cebde96 100644 --- a/client/go-cli/scientia-cli.go +++ b/client/go-cli/scientia-cli.go @@ -6,12 +6,13 @@ import ( "errors" "flag" "fmt" - "gopkg.in/yaml.v2" "io" "log" "math/rand" "net/http" "os" + + "gopkg.in/yaml.v2" ) /** @@ -30,7 +31,7 @@ import ( * along with this program. If not, see http://www.sun.com/cddl/cddl.html */ -const website = "https://www.bananas-playground.net/projekt/scientia" +const website = "https://www.bananas-playground.net/projekt/scientia/" const version = "1.0" // used for non-existing default config @@ -69,6 +70,10 @@ type Response struct { */ func main() { + // https://cli.urfave.org/v2/examples/arguments/ + // https://github.com/dnote/dnote + //https://github.com/spf13/cobra/blob/main/site/content/user_guide.md + // parse commandline parameters flag.BoolVar(&optsVerbose, "verbose", false, "Produce verbose output") flag.BoolVar(&optsCreateConfig, "create-config-file", false, "Create default config file") -- 2.39.5