Browse Source

some changes and maybe use cobra in the future

Banana 5 months ago
parent
commit
91f9c856cd
3 changed files with 43 additions and 23 deletions
  1. 18 7
      client/go-cli/Makefile
  2. 18 14
      client/go-cli/README.md
  3. 7 2
      client/go-cli/scientia-cli.go

+ 18 - 7
client/go-cli/Makefile

@@ -1,17 +1,28 @@
 all:
 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..."
 	@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..."
 	@echo "Building for linux/amd64 arch..."
 	GOOS=linux GOARCH=amd64 go build -o scientia-cli-linux-amd64
 	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..."
 	@echo "Building for windows/amd64 arch..."
 	GOOS=windows GOARCH=amd64 go build -o scientia-cli-windows-amd64
 	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..."
 	@echo "Building for macOS/amd64 arch..."
 	GOOS=darwin GOARCH=amd64 go build -o scientia-cli-darwin-amd64
 	GOOS=darwin GOARCH=amd64 go build -o scientia-cli-darwin-amd64
-	@echo "Done: scientia-cli-darwin-amd64"
+
+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

+ 18 - 14
client/go-cli/README → 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
 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!
 !WARNING!
 This is a very simple, with limited experience written, go program.
 This is a very simple, with limited experience written, go program.
 Use at own risk and feel free to improve.
 Use at own risk and feel free to improve.
 
 
 # Howto build
 # 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
 # Usage
+
 At first usage you need to create the config and the individual secret.
 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.
 Run $scientia-cli -create-config-file to create the default config file.
 The path to the config file is printed.
 The path to the config file is printed.
 Change the host address and update your server it with the secret, which is randomly created.
 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

+ 7 - 2
client/go-cli/scientia-cli.go

@@ -6,12 +6,13 @@ import (
 	"errors"
 	"errors"
 	"flag"
 	"flag"
 	"fmt"
 	"fmt"
-	"gopkg.in/yaml.v2"
 	"io"
 	"io"
 	"log"
 	"log"
 	"math/rand"
 	"math/rand"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
+
+	"gopkg.in/yaml.v2"
 )
 )
 
 
 /**
 /**
@@ -30,7 +31,7 @@ import (
  * along with this program.  If not, see http://www.sun.com/cddl/cddl.html
  * 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"
 const version = "1.0"
 
 
 // used for non-existing default config
 // used for non-existing default config
@@ -69,6 +70,10 @@ type Response struct {
  */
  */
 func main() {
 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
 	// parse commandline parameters
 	flag.BoolVar(&optsVerbose, "verbose", false, "Produce verbose output")
 	flag.BoolVar(&optsVerbose, "verbose", false, "Produce verbose output")
 	flag.BoolVar(&optsCreateConfig, "create-config-file", false, "Create default config file")
 	flag.BoolVar(&optsCreateConfig, "create-config-file", false, "Create default config file")