Skip to content

Commit 95ed86e

Browse files
committed
Code refactoring
1 parent ffefa17 commit 95ed86e

3 files changed

Lines changed: 20 additions & 25 deletions

File tree

cli/cli.go

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/essentialkaos/ek/v12/strutil"
2525
"github.com/essentialkaos/ek/v12/support"
2626
"github.com/essentialkaos/ek/v12/support/deps"
27+
"github.com/essentialkaos/ek/v12/terminal"
2728
"github.com/essentialkaos/ek/v12/timeutil"
2829
"github.com/essentialkaos/ek/v12/usage"
2930
"github.com/essentialkaos/ek/v12/usage/completion/bash"
@@ -39,7 +40,7 @@ import (
3940

4041
const (
4142
APP = "SSLScan Client"
42-
VER = "3.0.0"
43+
VER = "3.0.1"
4344
DESC = "Command-line client for the SSL Labs API"
4445
)
4546

@@ -156,8 +157,9 @@ func Run(gitRev string, gomod []byte) {
156157

157158
args, errs := options.Parse(optMap)
158159

159-
if len(errs) != 0 {
160-
printError(errs[0].Error())
160+
if !errs.IsEmpty() {
161+
terminal.Error("Options parsing errors:")
162+
terminal.Error(errs.String())
161163
os.Exit(1)
162164
}
163165

@@ -189,7 +191,7 @@ func Run(gitRev string, gomod []byte) {
189191
err = prepare()
190192

191193
if err != nil {
192-
printError(err.Error())
194+
terminal.Error(err)
193195
os.Exit(1)
194196
}
195197

@@ -201,7 +203,7 @@ func Run(gitRev string, gomod []byte) {
201203
}
202204

203205
if err != nil {
204-
printError(err.Error())
206+
terminal.Error(err)
205207
}
206208

207209
if !ok {
@@ -253,8 +255,8 @@ func checkForEmail() {
253255
return
254256
}
255257

256-
printError("You must provide an email address to make requests to the API.")
257-
printError(
258+
terminal.Error("You must provide an email address to make requests to the API.")
259+
terminal.Error(
258260
"You can provide it using %s option, or using SSLLABS_EMAIL environment variable.",
259261
options.Format(OPT_EMAIL),
260262
)
@@ -684,11 +686,6 @@ func getNormGrade(grade string) string {
684686
}
685687
}
686688

687-
// printError prints error message to console
688-
func printError(f string, a ...interface{}) {
689-
fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...)
690-
}
691-
692689
// ////////////////////////////////////////////////////////////////////////////////// //
693690

694691
// checkAPIAvailability checks SSLLabs API availability
@@ -735,12 +732,7 @@ func printCompletion() int {
735732

736733
// printMan prints man page
737734
func printMan() {
738-
fmt.Println(
739-
man.Generate(
740-
genUsage(),
741-
genAbout(""),
742-
),
743-
)
735+
fmt.Println(man.Generate(genUsage(), genAbout("")))
744736
}
745737

746738
// genUsage generates usage info

cli/details.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/essentialkaos/ek/v12/pluralize"
1919
"github.com/essentialkaos/ek/v12/sliceutil"
2020
"github.com/essentialkaos/ek/v12/strutil"
21+
"github.com/essentialkaos/ek/v12/terminal"
2122
"github.com/essentialkaos/ek/v12/timeutil"
2223

2324
sslscan "github.com/essentialkaos/sslscan/v14"
@@ -63,12 +64,12 @@ func printDetailedInfo(ap *sslscan.AnalyzeProgress, fromCache bool) {
6364
info, err := ap.Info(true, fromCache)
6465

6566
if err != nil {
66-
printError("\nCan't fetch full analyze info: %v\n", err)
67+
terminal.Error("\nCan't fetch full analyze info: %v\n", err)
6768
return
6869
}
6970

7071
if strings.ToUpper(info.Status) != "READY" {
71-
printError("\n%s\n", info.StatusMessage)
72+
terminal.Error("\n%s\n", info.StatusMessage)
7273
return
7374
}
7475

common/sslcli.spec

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
Summary: Pretty awesome command-line client for public SSLLabs API
1212
Name: sslcli
13-
Version: 3.0.0
13+
Version: 3.0.1
1414
Release: 0%{?dist}
1515
Group: Applications/System
1616
License: Apache License, Version 2.0
@@ -22,7 +22,7 @@ Source100: checksum.sha512
2222

2323
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
2424

25-
BuildRequires: golang >= 1.20
25+
BuildRequires: golang >= 1.21
2626

2727
Provides: %{name} = %{version}-%{release}
2828

@@ -37,13 +37,15 @@ Pretty awesome command-line client for public SSLLabs API.
3737
%{crc_check}
3838

3939
%setup -q
40-
41-
%build
4240
if [[ ! -d "%{name}/vendor" ]] ; then
43-
echo "This package requires vendored dependencies"
41+
echo -e "----\nThis package requires vendored dependencies\n----"
42+
exit 1
43+
elif [[ -f "%{name}/%{name}" ]] ; then
44+
echo -e "----\nSources must not contain precompiled binaries\n----"
4445
exit 1
4546
fi
4647

48+
%build
4749
pushd %{name}
4850
go build %{name}.go
4951
cp LICENSE ..

0 commit comments

Comments
 (0)