Skip to content

Commit

Permalink
Updated demo.gif and added colors. 🎨
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbeutler committed Dec 19, 2024
1 parent 5ce59a2 commit 8e94420
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
35 changes: 29 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"encoding/json"
"fmt"
"os"
"strings"

Expand All @@ -12,31 +14,31 @@ import (
)

var banner = []string{
" _ _ ",
"\033[32m _ _ ",
" | |_ _ __ _ ___ ____ _ _ __ ___ (_)",
" | __| '__| | | \\ \\ / / _` | '_ ` _ \\| |",
" | |_| | | |_| |\\ V / (_| | | | | | | |",
" \\__|_| \\__,_| \\_/ \\__,_|_| |_| |_|_|",
" \\__|_| \\__,_| \\_/ \\__,_|_| |_| |_|_|\033[0m",
}

var Debug bool
var Json bool
var AutoPadding bool

func init() {
rootCmd.PersistentFlags().BoolVarP(&Debug, "debug", "d", false, "Display debugging output in the console. (default: false)")
rootCmd.PersistentFlags().BoolVarP(&Debug, "debug", "d", false, "Display debugging output in the console. (default: \033[31mfalse\033[0m)")
err := viper.BindPFlag("debug", rootCmd.PersistentFlags().Lookup("debug"))
if err != nil {
logger.Logger.Error("error while binding debug flag", zap.Error(err))
}

rootCmd.PersistentFlags().BoolVarP(&Json, "json", "j", false, "Output the result in JSON format. (default: false)")
rootCmd.PersistentFlags().BoolVarP(&Json, "json", "j", false, "Output the result in JSON format. (default: \033[31mfalse\033[0m)")
err = viper.BindPFlag("json", rootCmd.PersistentFlags().Lookup("json"))
if err != nil {
logger.Logger.Error("error while binding json flag", zap.Error(err))
}

rootCmd.PersistentFlags().BoolVarP(&AutoPadding, "auto-padding", "", false, "Enable automatic padding of payload. (default: false)\nWarning: this may lead to corrupted data.")
rootCmd.PersistentFlags().BoolVarP(&AutoPadding, "auto-padding", "", false, "Enable automatic padding of payload. (default: \033[31mfalse\033[0m)\n\033[33mWarning:\033[0m this may lead to corrupted data.")
err = viper.BindPFlag("auto-padding", rootCmd.PersistentFlags().Lookup("auto-padding"))
if err != nil {
logger.Logger.Error("error while binding auto-padding flag", zap.Error(err))
Expand Down Expand Up @@ -87,5 +89,26 @@ func Execute() {
}

func printJSON(data interface{}, metadata interface{}) {
logger.Logger.Info("successfully decoded payload", zap.Any("data", data), zap.Any("metadata", metadata))
if Json {
logger.Logger.Info("successfully decoded payload", zap.Any("data", data), zap.Any("metadata", metadata))
return
}

logger.Logger.Info("successfully decoded payload")

// print data and metadata beautifully and formatted
marshaled, err := json.MarshalIndent(map[string]interface{}{
"data": data,
"metadata": metadata,
}, "", " ")

// handle marshaling error
if err != nil {
logger.Logger.Fatal("marshaling error", zap.Error(err))
}

// print the marshaled data
fmt.Println()
fmt.Println(string(marshaled))
fmt.Println()
}
Binary file modified demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions demo.tape
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ Set FontSize 12
Set Width 800
Set Height 600

Type "decoder help" Sleep 500ms Enter

Sleep 5s

Type "decoder tagsl 1 8002cdcd1300744f5e166018040b14341a" Sleep 500ms Enter

Sleep 5s
Expand All @@ -74,6 +78,6 @@ Type "decoder tagsl 4 0000003c0000012c000151800078012c05dc02020100010200005460 -

Sleep 5s

Type "docker run ghcr.io/truvami/decoder:alpine-arm64 decoder tagsl 1 8002cdcd1300744f5e166018040b14341a --json | jq" Sleep 500ms Enter

Sleep 5s
# Type "docker run ghcr.io/truvami/decoder:alpine-arm64 decoder tagsl 1 8002cdcd1300744f5e166018040b14341a --json | jq" Sleep 500ms Enter
#
# Sleep 5s

0 comments on commit 8e94420

Please sign in to comment.