Skip to content

Commit

Permalink
Merge pull request #109 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 2.7.4
  • Loading branch information
andyone committed Mar 22, 2023
2 parents 1ecc30a + f8f10e0 commit 78ef233
Show file tree
Hide file tree
Showing 13 changed files with 316 additions and 144 deletions.
4 changes: 1 addition & 3 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ _Before opening an issue, search for similar bug reports or feature requests on

**System info:**

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

**Steps to reproduce:**
Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ on:
branches: [master]
schedule:
- cron: '0 13 */15 * *'
workflow_dispatch:
inputs:
force_run:
description: 'Force workflow run'
required: true
type: choice
options: [yes, no]

permissions:
actions: read
contents: read
statuses: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -22,11 +34,11 @@ jobs:

strategy:
matrix:
go: [ '1.18.x', '1.19.x' ]
go: [ '1.19.x', '1.20.x' ]

steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

Expand All @@ -51,9 +63,9 @@ jobs:

steps:
- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: '1.18.x'
go-version: '1.19.x'

- name: Checkout
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
- name: Build and push Docker images (Docker)
if: ${{ steps.build_check.outputs.build == 'true' }}
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
push: true
context: .
Expand All @@ -148,7 +148,7 @@ jobs:
- name: Build and push Docker images (GHCR)
if: ${{ steps.build_check.outputs.build == 'true' }}
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
push: true
context: .
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################

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

################################################################################
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#### From source

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

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

#### Docker Image

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):

```bash
docker pull essentialkaos/sslcli:latest
docker run --rm -it essentialkaos/sslcli:latest mydomain.com
```

or
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):

```bash
docker pull ghcr.io/essentialkaos/sslcli:latest
Expand Down
122 changes: 69 additions & 53 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cli

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2022 ESSENTIAL KAOS //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down Expand Up @@ -30,13 +30,15 @@ import (
"github.com/essentialkaos/ek/v12/usage/update"

"github.com/essentialkaos/sslscan/v13"

"github.com/essentialkaos/sslcli/cli/support"
)

// ////////////////////////////////////////////////////////////////////////////////// //

const (
APP = "SSLScan Client"
VER = "2.7.3"
VER = "2.7.4"
DESC = "Command-line client for the SSL Labs API"
)

Expand All @@ -54,6 +56,7 @@ const (
OPT_HELP = "h:help"
OPT_VER = "v:version"

OPT_VERB_VER = "vv:verbose-version"
OPT_COMPLETION = "completion"
OPT_GENERATE_MAN = "generate-man"
)
Expand Down Expand Up @@ -100,9 +103,10 @@ var optMap = options.Map{
OPT_QUIET: {Type: options.BOOL},
OPT_NOTIFY: {Type: options.BOOL},
OPT_NO_COLOR: {Type: options.BOOL},
OPT_HELP: {Type: options.BOOL, Alias: "u:usage"},
OPT_VER: {Type: options.BOOL, Alias: "ver"},
OPT_HELP: {Type: options.BOOL},
OPT_VER: {Type: options.BOOL},

OPT_VERB_VER: {Type: options.BOOL},
OPT_COMPLETION: {},
OPT_GENERATE_MAN: {Type: options.BOOL},
}
Expand All @@ -127,44 +131,64 @@ var serverMessageShown bool

// ////////////////////////////////////////////////////////////////////////////////// //

// Init starts initialization rutine
func Init() {
args, errs := options.Parse(optMap)
// Run is main function
func Run(gitRev string, gomod []byte) {
runtime.GOMAXPROCS(2)

if len(errs) != 0 {
printError("Arguments parsing errors:")
preConfigureUI()

for _, err := range errs {
printError(" %v", err)
}
args, errs := options.Parse(optMap)

if len(errs) != 0 {
printError(errs[0].Error())
os.Exit(1)
}

if options.Has(OPT_COMPLETION) {
os.Exit(genCompletion())
}

if options.Has(OPT_GENERATE_MAN) {
os.Exit(genMan())
}

configureUI()
prepare()

if options.GetB(OPT_VER) {
showAbout()
return
switch {
case options.Has(OPT_COMPLETION):
os.Exit(printCompletion())
case options.Has(OPT_GENERATE_MAN):
printMan()
os.Exit(0)
case options.GetB(OPT_VER):
genAbout(gitRev).Print()
os.Exit(0)
case options.GetB(OPT_VERB_VER):
support.Print(APP, VER, gitRev, gomod)
os.Exit(0)
case options.GetB(OPT_HELP) || len(args) == 0:
genUsage().Print()
os.Exit(0)
}

if options.GetB(OPT_HELP) || len(args) == 0 {
showUsage()
return
process(args)
}

// preConfigureUI preconfigures UI based on information about user terminal
func preConfigureUI() {
term := os.Getenv("TERM")

fmtc.DisableColors = true

if term != "" {
switch {
case strings.Contains(term, "xterm"),
strings.Contains(term, "color"),
term == "screen":
fmtc.DisableColors = false
}
}

runtime.GOMAXPROCS(2)
if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" {
fmtc.DisableColors = true
}

process(args)
if os.Getenv("NO_COLOR") != "" {
fmtc.DisableColors = true
}
}

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

// ////////////////////////////////////////////////////////////////////////////////// //

// showUsage prints usage info
func showUsage() {
genUsage().Render()
}

// showAbout prints info about version
func showAbout() {
genAbout().Render()
}

// genMan generates man page
func genMan() int {
fmt.Println(
man.Generate(
genUsage(),
genAbout(),
),
)

return 0
}

// genCompletion generates completion for different shells
func genCompletion() int {
// printCompletion prints completion for given shell
func printCompletion() int {
info := genUsage()

switch options.GetS(OPT_COMPLETION) {
Expand All @@ -634,6 +636,16 @@ func genCompletion() int {
return 0
}

// printMan prints man page
func printMan() {
fmt.Println(
man.Generate(
genUsage(),
genAbout(""),
),
)
}

// genUsage generates usage info
func genUsage() *usage.Info {
info := usage.NewInfo("", "host…")
Expand Down Expand Up @@ -661,7 +673,7 @@ func genUsage() *usage.Info {
}

// genAbout generates info about version
func genAbout() *usage.About {
func genAbout(gitRev string) *usage.About {
about := &usage.About{
App: APP,
Version: VER,
Expand All @@ -672,5 +684,9 @@ func genAbout() *usage.About {
UpdateChecker: usage.UpdateChecker{"essentialkaos/sslcli", update.GitHubChecker},
}

if gitRev != "" {
about.Build = "git:" + gitRev
}

return about
}
2 changes: 1 addition & 1 deletion cli/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cli

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2022 ESSENTIAL KAOS //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
2 changes: 1 addition & 1 deletion cli/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cli

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2022 ESSENTIAL KAOS //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
Loading

0 comments on commit 78ef233

Please sign in to comment.