Skip to content

Commit

Permalink
refactor: organize
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Aug 16, 2023
1 parent c79b38c commit 1287124
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
21 changes: 0 additions & 21 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,6 @@ var (
date = "unknown"
)

// ANSI colors
var colors = map[string]string{
"black": "\033[1;30m%s\033[0m",
"red": "\033[1;31m%s\033[0m",
"green": "\033[1;32m%s\033[0m",
"yellow": "\033[1;33m%s\033[0m",
"purple": "\033[1;34m%s\033[0m",
"magenta": "\033[1;35m%s\033[0m",
"teal": "\033[1;36m%s\033[0m",
"white": "\033[1;37m%s\033[0m",
}

var tlsCipherSuiteToInt = map[string]uint16{
// TLS 1.0 - 1.2
"TLS_RSA_WITH_RC4_128_SHA": tls.TLS_RSA_WITH_RC4_128_SHA,
Expand Down Expand Up @@ -151,15 +139,6 @@ func parseTLSCipherSuites(cipherSuites []string) []uint16 {
return cipherSuiteInts
}

// color returns a color formatted string
func color(color string, args ...interface{}) string {
if opts.Color {
return fmt.Sprintf(colors[color], fmt.Sprint(args...))
} else {
return fmt.Sprint(args...)
}
}

// clearOpts sets the default values for the CLI options
func clearOpts() {
opts = optsTemplate{}
Expand Down
21 changes: 21 additions & 0 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@ import (

var existingRRs = map[string]bool{}

// ANSI colors
var colors = map[string]string{
"black": "\033[1;30m%s\033[0m",
"red": "\033[1;31m%s\033[0m",
"green": "\033[1;32m%s\033[0m",
"yellow": "\033[1;33m%s\033[0m",
"purple": "\033[1;34m%s\033[0m",
"magenta": "\033[1;35m%s\033[0m",
"teal": "\033[1;36m%s\033[0m",
"white": "\033[1;37m%s\033[0m",
}

// color returns a color formatted string
func color(color string, args ...interface{}) string {
if opts.Color {
return fmt.Sprintf(colors[color], fmt.Sprint(args...))
} else {
return fmt.Sprint(args...)
}
}

func mustWriteln(out io.Writer, s string) {
if _, err := out.Write([]byte(s + "\n")); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 1287124

Please sign in to comment.