aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-04-01 21:33:45 +0200
committersalaaad2 <arthurdurant263@gmail.com>2022-04-01 21:33:45 +0200
commit516b165421855538e10f41919f1fa72e1fa58912 (patch)
tree81c3f9a6e6af2d84493b87893ed633a470f7cfe0
parent0.0.1.1 (diff)
downloadsmith-516b165421855538e10f41919f1fa72e1fa58912.tar.gz
smith-516b165421855538e10f41919f1fa72e1fa58912.tar.bz2
smith-516b165421855538e10f41919f1fa72e1fa58912.tar.xz
smith-516b165421855538e10f41919f1fa72e1fa58912.tar.zst
smith-516b165421855538e10f41919f1fa72e1fa58912.zip
hehe
-rw-r--r--.gitignore1
-rw-r--r--Makefile3
-rw-r--r--gosrc/colors.go27
-rw-r--r--gosrc/main.go47
-rw-r--r--main.go49
-rw-r--r--sample_config.json5
6 files changed, 82 insertions, 50 deletions
diff --git a/.gitignore b/.gitignore
index 1aea797..0834f94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
.DS_Store
.idea
+config.json
*.log
tmp/
csrc/obj
diff --git a/Makefile b/Makefile
index 6119205..d7e2482 100644
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,7 @@ C_NAME = libsmith.a
NAME = smith
CC = clang
GO = go
+GO_DIR = gosrc/
#------------------------------------------------------------------------------#
CFLAGS = -O2
CFLAGS += -Wall -Werror -Wextra -pedantic
@@ -68,7 +69,7 @@ ${C_NAME}: ${OBJS_DIR} ${OBJS} ${INCS}
#==============================================================================#
#------------------------------------------------------------------------------#
all: ${C_NAME}
- go build
+ go build -o ./smith gosrc/*
#------------------------------------------------------------------------------#
clean:
rm -rvf ${OBJS_DIR} ${OUT_DIR}${NAME}
diff --git a/gosrc/colors.go b/gosrc/colors.go
new file mode 100644
index 0000000..6fdf98a
--- /dev/null
+++ b/gosrc/colors.go
@@ -0,0 +1,27 @@
+package main
+
+// Theme defines the colors used when primitives are initialized.
+type Theme struct {
+ colorReset string // Main background color for primitives.
+ colorRed string // Background color for contrasting elements.
+ colorGreen string // Background color for even more contrasting elements.
+ colorYellow string // Box borders.
+ colorBlue string // Box titles.
+ colorPurple string // Graphics.
+ colorCyan string // Primary text.
+ colorWhite string // Secondary text (e.g. labels).
+}
+
+// Styles defines the theme for applications. The default is for a black
+// background and some basic colors: black, white, yellow, green, cyan, and
+// blue.
+var Styles = Theme{
+ colorReset: "\033[0m",
+ colorRed : "\033[31m",
+ colorGreen : "\033[32m",
+ colorYellow : "\033[33m",
+ colorBlue : "\033[34m",
+ colorPurple : "\033[35m",
+ colorCyan : "\033[36m",
+ colorWhite : "\033[37m",
+}
diff --git a/gosrc/main.go b/gosrc/main.go
new file mode 100644
index 0000000..27cec39
--- /dev/null
+++ b/gosrc/main.go
@@ -0,0 +1,47 @@
+// SMITH ( // /
+// main ( )/ /
+// by salade )(/ /
+// ________________ ( /) /
+// ()__)____________))))) :^} /
+
+package main
+
+import (
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "log"
+)
+
+// #include "../csrc/smith.h"
+// #cgo LDFLAGS: -lsmith -L../
+import "C"
+
+type Config struct {
+ Public_key string
+ Secret_key string
+ Mirror string
+}
+
+func main() {
+ fmt.Println("Welcome, traveller, my name is " + Styles.colorGreen + C.GoString(C.mr_smith()) + Styles.colorReset +
+ "\nI will try to help you get the bag...")
+
+ config_path := "./config.json"
+ config_content, err := ioutil.ReadFile(config_path)
+ if err != nil {
+ log.Fatal("config file not found")
+ }
+
+ var config Config
+ err = json.Unmarshal(config_content, &config)
+
+ if err != nil {
+ log.Fatal("error during marshall() ", err)
+ }
+
+ fmt.Println("\n" +
+ Styles.colorBlue + "public_key: " + Styles.colorReset + config.Public_key + "\n" +
+ Styles.colorBlue + "secret_key: " + Styles.colorReset + config.Secret_key + "\n" +
+ Styles.colorBlue + "mirror: " + Styles.colorReset + config.Mirror)
+}
diff --git a/main.go b/main.go
deleted file mode 100644
index f01a58f..0000000
--- a/main.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// SMITH ( // /
-// main ( )/ /
-// by salade )(/ /
-// ________________ ( /) /
-// ()__)____________))))) :^} /
-
-package main
-
-import (
- "github.com/rivo/tview"
-)
-
-// #include "csrc/smith.h"
-// #cgo LDFLAGS: -lsmith -L.
-import "C"
-
-func main() {
- smith := tview.NewApplication()
- ctogo := C.mr_smith()
-
- modal := func(p tview.Primitive, width, height int) tview.Primitive {
- return tview.NewFlex().
- AddItem(nil, 0, 1, false).
- AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
- AddItem(nil, 0, 1, false).
- AddItem(p, height, 1, false).
- AddItem(nil, 0, 1, false), width, 1, false).
- AddItem(nil, 0, 1, false)
- }
-
- box := tview.NewBox().SetBorder(true).SetTitle(C.GoString(ctogo))
-
-
- init_form := tview.NewForm().
- AddDropDown("You are", []string{"Salad", "Salade", "Mr Smith"}, 0, nil).
- AddInputField("First Name", "", 20, nil, nil).
- AddButton("Save", nil).
- AddButton("Quit", func() {
- smith.Stop()
- })
-
- pages := tview.NewPages().
- AddPage("box", box, true, true).
- AddPage("form", modal(init_form, 40, 20), true, true)
-
- if err := smith.SetRoot(pages, true).Run(); err != nil {
- panic(err)
- }
-}
diff --git a/sample_config.json b/sample_config.json
new file mode 100644
index 0000000..db566fb
--- /dev/null
+++ b/sample_config.json
@@ -0,0 +1,5 @@
+{
+ "public_key": "lol",
+ "secret_key": "hehe",
+ "mirror": "api.binance.com"
+}