Skip to content

Commit 78ef233

Browse files
authored
Merge pull request #109 from essentialkaos/develop
Version 2.7.4
2 parents 1ecc30a + f8f10e0 commit 78ef233

File tree

13 files changed

+316
-144
lines changed

13 files changed

+316
-144
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ _Before opening an issue, search for similar bug reports or feature requests on
44

55
**System info:**
66

7-
* **Version used (`sslcli -v`):**
8-
* **OS (e.g. from `/etc/*-release`):**
9-
* **Kernel (`uname -a`):**
7+
* **Verbose version info (`sslcli -vv`):**
108
* **Install tools:**
119

1210
**Steps to reproduce:**

.github/workflows/ci.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ on:
77
branches: [master]
88
schedule:
99
- cron: '0 13 */15 * *'
10+
workflow_dispatch:
11+
inputs:
12+
force_run:
13+
description: 'Force workflow run'
14+
required: true
15+
type: choice
16+
options: [yes, no]
17+
18+
permissions:
19+
actions: read
20+
contents: read
21+
statuses: write
1022

1123
concurrency:
1224
group: ${{ github.workflow }}-${{ github.ref }}
@@ -22,11 +34,11 @@ jobs:
2234

2335
strategy:
2436
matrix:
25-
go: [ '1.18.x', '1.19.x' ]
37+
go: [ '1.19.x', '1.20.x' ]
2638

2739
steps:
2840
- name: Set up Go
29-
uses: actions/setup-go@v3
41+
uses: actions/setup-go@v4
3042
with:
3143
go-version: ${{ matrix.go }}
3244

@@ -51,9 +63,9 @@ jobs:
5163

5264
steps:
5365
- name: Set up Go
54-
uses: actions/setup-go@v3
66+
uses: actions/setup-go@v4
5567
with:
56-
go-version: '1.18.x'
68+
go-version: '1.19.x'
5769

5870
- name: Checkout
5971
uses: actions/checkout@v3

.github/workflows/docker-push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
136136
- name: Build and push Docker images (Docker)
137137
if: ${{ steps.build_check.outputs.build == 'true' }}
138-
uses: docker/build-push-action@v3
138+
uses: docker/build-push-action@v4
139139
with:
140140
push: true
141141
context: .
@@ -148,7 +148,7 @@ jobs:
148148
149149
- name: Build and push Docker images (GHCR)
150150
if: ${{ steps.build_check.outputs.build == 'true' }}
151-
uses: docker/build-push-action@v3
151+
uses: docker/build-push-action@v4
152152
with:
153153
push: true
154154
context: .

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
################################################################################
22

3-
# This Makefile generated by GoMakeGen 2.1.0 using next command:
3+
# This Makefile generated by GoMakeGen 2.2.0 using next command:
44
# gomakegen --mod .
55
#
66
# More info: https://kaos.sh/gomakegen
@@ -94,6 +94,6 @@ help: ## Show this info
9494
| sed 's/ifdef //' \
9595
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}'
9696
@echo -e ''
97-
@echo -e '\033[90mGenerated by GoMakeGen 2.1.0\033[0m\n'
97+
@echo -e '\033[90mGenerated by GoMakeGen 2.2.0\033[0m\n'
9898

9999
################################################################################

README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#### From source
2626

27-
To build the SSLScan Client from scratch, make sure you have a working Go 1.17+ workspace ([instructions](https://golang.org/doc/install)), then:
27+
To build the SSLScan Client from scratch, make sure you have a working Go 1.19+ workspace ([instructions](https://golang.org/doc/install)), then:
2828

2929
```
3030
go install github.com/essentialkaos/sslcli@latest
@@ -47,14 +47,7 @@ bash <(curl -fsSL https://apps.kaos.st/get) sslcli
4747

4848
#### Docker Image
4949

50-
The latest version of `sslcli` also available as Docker image on [Docker Hub](https://kaos.sh/d/sslcli) and [GitHub Container Registry](https://kaos.sh/p/sslcli):
51-
52-
```bash
53-
docker pull essentialkaos/sslcli:latest
54-
docker run --rm -it essentialkaos/sslcli:latest mydomain.com
55-
```
56-
57-
or
50+
The latest version of `sslcli` also available as Docker image on [GitHub Container Registry](https://kaos.sh/p/sslcli) and [Docker Hub](https://kaos.sh/d/sslcli):
5851

5952
```bash
6053
docker pull ghcr.io/essentialkaos/sslcli:latest

cli/cli.go

Lines changed: 69 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cli
22

33
// ////////////////////////////////////////////////////////////////////////////////// //
44
// //
5-
// Copyright (c) 2022 ESSENTIAL KAOS //
5+
// Copyright (c) 2023 ESSENTIAL KAOS //
66
// Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> //
77
// //
88
// ////////////////////////////////////////////////////////////////////////////////// //
@@ -30,13 +30,15 @@ import (
3030
"github.com/essentialkaos/ek/v12/usage/update"
3131

3232
"github.com/essentialkaos/sslscan/v13"
33+
34+
"github.com/essentialkaos/sslcli/cli/support"
3335
)
3436

3537
// ////////////////////////////////////////////////////////////////////////////////// //
3638

3739
const (
3840
APP = "SSLScan Client"
39-
VER = "2.7.3"
41+
VER = "2.7.4"
4042
DESC = "Command-line client for the SSL Labs API"
4143
)
4244

@@ -54,6 +56,7 @@ const (
5456
OPT_HELP = "h:help"
5557
OPT_VER = "v:version"
5658

59+
OPT_VERB_VER = "vv:verbose-version"
5760
OPT_COMPLETION = "completion"
5861
OPT_GENERATE_MAN = "generate-man"
5962
)
@@ -100,9 +103,10 @@ var optMap = options.Map{
100103
OPT_QUIET: {Type: options.BOOL},
101104
OPT_NOTIFY: {Type: options.BOOL},
102105
OPT_NO_COLOR: {Type: options.BOOL},
103-
OPT_HELP: {Type: options.BOOL, Alias: "u:usage"},
104-
OPT_VER: {Type: options.BOOL, Alias: "ver"},
106+
OPT_HELP: {Type: options.BOOL},
107+
OPT_VER: {Type: options.BOOL},
105108

109+
OPT_VERB_VER: {Type: options.BOOL},
106110
OPT_COMPLETION: {},
107111
OPT_GENERATE_MAN: {Type: options.BOOL},
108112
}
@@ -127,44 +131,64 @@ var serverMessageShown bool
127131

128132
// ////////////////////////////////////////////////////////////////////////////////// //
129133

130-
// Init starts initialization rutine
131-
func Init() {
132-
args, errs := options.Parse(optMap)
134+
// Run is main function
135+
func Run(gitRev string, gomod []byte) {
136+
runtime.GOMAXPROCS(2)
133137

134-
if len(errs) != 0 {
135-
printError("Arguments parsing errors:")
138+
preConfigureUI()
136139

137-
for _, err := range errs {
138-
printError(" %v", err)
139-
}
140+
args, errs := options.Parse(optMap)
140141

142+
if len(errs) != 0 {
143+
printError(errs[0].Error())
141144
os.Exit(1)
142145
}
143146

144-
if options.Has(OPT_COMPLETION) {
145-
os.Exit(genCompletion())
146-
}
147-
148-
if options.Has(OPT_GENERATE_MAN) {
149-
os.Exit(genMan())
150-
}
151-
152147
configureUI()
153148
prepare()
154149

155-
if options.GetB(OPT_VER) {
156-
showAbout()
157-
return
150+
switch {
151+
case options.Has(OPT_COMPLETION):
152+
os.Exit(printCompletion())
153+
case options.Has(OPT_GENERATE_MAN):
154+
printMan()
155+
os.Exit(0)
156+
case options.GetB(OPT_VER):
157+
genAbout(gitRev).Print()
158+
os.Exit(0)
159+
case options.GetB(OPT_VERB_VER):
160+
support.Print(APP, VER, gitRev, gomod)
161+
os.Exit(0)
162+
case options.GetB(OPT_HELP) || len(args) == 0:
163+
genUsage().Print()
164+
os.Exit(0)
158165
}
159166

160-
if options.GetB(OPT_HELP) || len(args) == 0 {
161-
showUsage()
162-
return
167+
process(args)
168+
}
169+
170+
// preConfigureUI preconfigures UI based on information about user terminal
171+
func preConfigureUI() {
172+
term := os.Getenv("TERM")
173+
174+
fmtc.DisableColors = true
175+
176+
if term != "" {
177+
switch {
178+
case strings.Contains(term, "xterm"),
179+
strings.Contains(term, "color"),
180+
term == "screen":
181+
fmtc.DisableColors = false
182+
}
163183
}
164184

165-
runtime.GOMAXPROCS(2)
185+
if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" {
186+
fmtc.DisableColors = true
187+
}
166188

167-
process(args)
189+
if os.Getenv("NO_COLOR") != "" {
190+
fmtc.DisableColors = true
191+
}
168192
}
169193

170194
// configureUI configures user interface
@@ -594,30 +618,8 @@ func printError(f string, a ...interface{}) {
594618

595619
// ////////////////////////////////////////////////////////////////////////////////// //
596620

597-
// showUsage prints usage info
598-
func showUsage() {
599-
genUsage().Render()
600-
}
601-
602-
// showAbout prints info about version
603-
func showAbout() {
604-
genAbout().Render()
605-
}
606-
607-
// genMan generates man page
608-
func genMan() int {
609-
fmt.Println(
610-
man.Generate(
611-
genUsage(),
612-
genAbout(),
613-
),
614-
)
615-
616-
return 0
617-
}
618-
619-
// genCompletion generates completion for different shells
620-
func genCompletion() int {
621+
// printCompletion prints completion for given shell
622+
func printCompletion() int {
621623
info := genUsage()
622624

623625
switch options.GetS(OPT_COMPLETION) {
@@ -634,6 +636,16 @@ func genCompletion() int {
634636
return 0
635637
}
636638

639+
// printMan prints man page
640+
func printMan() {
641+
fmt.Println(
642+
man.Generate(
643+
genUsage(),
644+
genAbout(""),
645+
),
646+
)
647+
}
648+
637649
// genUsage generates usage info
638650
func genUsage() *usage.Info {
639651
info := usage.NewInfo("", "host…")
@@ -661,7 +673,7 @@ func genUsage() *usage.Info {
661673
}
662674

663675
// genAbout generates info about version
664-
func genAbout() *usage.About {
676+
func genAbout(gitRev string) *usage.About {
665677
about := &usage.About{
666678
App: APP,
667679
Version: VER,
@@ -672,5 +684,9 @@ func genAbout() *usage.About {
672684
UpdateChecker: usage.UpdateChecker{"essentialkaos/sslcli", update.GitHubChecker},
673685
}
674686

687+
if gitRev != "" {
688+
about.Build = "git:" + gitRev
689+
}
690+
675691
return about
676692
}

cli/details.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cli
22

33
// ////////////////////////////////////////////////////////////////////////////////// //
44
// //
5-
// Copyright (c) 2022 ESSENTIAL KAOS //
5+
// Copyright (c) 2023 ESSENTIAL KAOS //
66
// Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> //
77
// //
88
// ////////////////////////////////////////////////////////////////////////////////// //

cli/encoder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cli
22

33
// ////////////////////////////////////////////////////////////////////////////////// //
44
// //
5-
// Copyright (c) 2022 ESSENTIAL KAOS //
5+
// Copyright (c) 2023 ESSENTIAL KAOS //
66
// Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> //
77
// //
88
// ////////////////////////////////////////////////////////////////////////////////// //

0 commit comments

Comments
 (0)