From: Banana Date: Thu, 28 Mar 2024 14:44:56 +0000 (+0100) Subject: some changes and maybe use cobra in the future X-Git-Tag: 1.1~11 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=91f9c856cd5da86f086b66e77e781bbd12774f98;p=scientia.git some changes and maybe use cobra in the future --- 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 deleted file mode 100644 index a8b2fc3..0000000 --- a/client/go-cli/README +++ /dev/null @@ -1,28 +0,0 @@ -This is a terminal cli client written in go to be used with 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. - -# 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 diff --git a/client/go-cli/README.md b/client/go-cli/README.md new file mode 100644 index 0000000..04ff93f --- /dev/null +++ b/client/go-cli/README.md @@ -0,0 +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/ + +!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 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. + +## 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")