diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fc51337..d0ad1de 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -14,6 +14,12 @@ updates: - "andyone" reviewers: - "andyone" + groups: + all: + applies-to: version-updates + update-types: + - "minor" + - "patch" - package-ecosystem: "github-actions" directory: "/" diff --git a/.github/images/card.svg b/.github/images/card.svg new file mode 100644 index 0000000..72e0453 --- /dev/null +++ b/.github/images/card.svg @@ -0,0 +1,4 @@ + + + + diff --git a/.github/images/license.svg b/.github/images/license.svg new file mode 100644 index 0000000..8990e77 --- /dev/null +++ b/.github/images/license.svg @@ -0,0 +1 @@ +license: Apache-2.0licenseApache-2.0 \ No newline at end of file diff --git a/.github/images/usage.svg b/.github/images/usage.svg new file mode 100644 index 0000000..62f00ad --- /dev/null +++ b/.github/images/usage.svg @@ -0,0 +1,77 @@ + + + + Redis CLI Monitor Usage + + + + + + + + + + + + + + + + + + + Terminal + + Usage: redis-cli-monitor {options} command-name + Options + --host, -h ip/host ....... Server hostname (127.0.0.1 by default) + --port, -p port .......... Server port (6379 by default) + --db, -n db .............. Database number + --raw, -r ................ Print raw data + --password, -a password .. Password to use when connecting to the server + --timeout, -t 1-300 ...... Connection timeout in seconds (3 by default) + --no-color, -nc .......... Disable colors in output + --help ................... Show this help message + --version, -v ............ Show version + Examples + redis-cli-monitor --host 192.168.0.123 --port 6821 --timeout 15 RENAMED_MONITOR + Execute "RENAMED_MONITOR" command on 192.168.0.123:6821 with 15 sec timeout + redis-cli-monitor -p 6378 -a MySuppaPassword1234 RENAMED_MONITOR + Execute "RENAMED_MONITOR" command on 127.0.0.1:6378 with password + "MySuppaPassword1234" + + + diff --git a/Makefile b/Makefile index 9439b57..5595c82 100644 --- a/Makefile +++ b/Makefile @@ -1,38 +1,40 @@ ################################################################################ -# This Makefile generated by GoMakeGen 2.2.0 using next command: +# This Makefile generated by GoMakeGen 3.0.2 using next command: # gomakegen --mod . # # More info: https://kaos.sh/gomakegen ################################################################################ -export GO111MODULE=on - ifdef VERBOSE ## Print verbose information (Flag) VERBOSE_FLAG = -v endif +COMPAT ?= 1.19 MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD) ################################################################################ .DEFAULT_GOAL := help -.PHONY = fmt vet all clean deps update init vendor mod-init mod-update mod-download mod-vendor help +.PHONY = fmt vet all install uninstall clean deps update init vendor mod-init mod-update mod-download mod-vendor help ################################################################################ all: redis-cli-monitor ## Build all binaries redis-cli-monitor: - go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" redis-cli-monitor.go + @echo "Building redis-cli-monitor…" + @go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" redis-cli-monitor.go install: ## Install all binaries - cp redis-cli-monitor /usr/bin/redis-cli-monitor + @echo "Installing binaries…" + @cp redis-cli-monitor /usr/bin/redis-cli-monitor uninstall: ## Uninstall all binaries - rm -f /usr/bin/redis-cli-monitor + @echo "Removing installed binaries…" + @rm -f /usr/bin/redis-cli-monitor init: mod-init ## Initialize new module @@ -43,57 +45,70 @@ update: mod-update ## Update dependencies to the latest versions vendor: mod-vendor ## Make vendored copy of dependencies mod-init: + @echo "[1/2] Modules initialization…" ifdef MODULE_PATH ## Module path for initialization (String) - go mod init $(MODULE_PATH) + @go mod init $(MODULE_PATH) else - go mod init + @go mod init endif + @echo "[2/2] Dependencies cleanup…" ifdef COMPAT ## Compatible Go version (String) - go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) + @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT) else - go mod tidy $(VERBOSE_FLAG) + @go mod tidy $(VERBOSE_FLAG) endif mod-update: + @echo "[1/4] Updating dependencies…" ifdef UPDATE_ALL ## Update all dependencies (Flag) - go get -u $(VERBOSE_FLAG) all + @go get -u $(VERBOSE_FLAG) all else - go get -u $(VERBOSE_FLAG) ./... + @go get -u $(VERBOSE_FLAG) ./... endif + @echo "[2/4] Stripping toolchain info…" + @grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || : + + @echo "[3/4] Dependencies cleanup…" ifdef COMPAT - go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) + @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) else - go mod tidy $(VERBOSE_FLAG) + @go mod tidy $(VERBOSE_FLAG) endif - test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : + @echo "[4/4] Updating vendored dependencies…" + @test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : mod-download: - go mod download + @echo "Downloading dependencies…" + @go mod download mod-vendor: - rm -rf vendor && go mod vendor $(VERBOSE_FLAG) + @echo "Vendoring dependencies…" + @rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || : fmt: ## Format source code with gofmt - find . -name "*.go" -exec gofmt -s -w {} \; + @echo "Formatting sources…" + @find . -name "*.go" -exec gofmt -s -w {} \; vet: ## Runs 'go vet' over sources - go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./... + @echo "Running 'go vet' over sources…" + @go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./... clean: ## Remove generated files - rm -f redis-cli-monitor + @echo "Removing built binaries…" + @rm -f redis-cli-monitor help: ## Show this info @echo -e '\n\033[1mTargets:\033[0m\n' @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \ - | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-19s\033[0m %s\n", $$1, $$2}' + | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-9s\033[0m %s\n", $$1, $$2}' @echo -e '\n\033[1mVariables:\033[0m\n' @grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \ | sed 's/ifdef //' \ - | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}' + | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-11s\033[0m %s\n", $$1, $$2}' @echo -e '' - @echo -e '\033[90mGenerated by GoMakeGen 2.2.0\033[0m\n' + @echo -e '\033[90mGenerated by GoMakeGen 3.0.2\033[0m\n' ################################################################################ diff --git a/README.md b/README.md index 520c974..827747c 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -

+

GitHub Actions CI Status GoReportCard codebeat badge GitHub Actions CodeQL Status - +

-

Usage demo • Installation • Usage • Build Status • License

+

Usage demo • Installation • Usage • CI Status • License


@@ -22,16 +22,16 @@ Tiny Redis client for renamed `MONITOR` commands. #### From source -To build the `redis-cli-monitor` from scratch, make sure you have a working Go 1.18+ workspace ([instructions](https://go.dev/doc/install)), then: +To build the `redis-cli-monitor` from scratch, make sure you have a working Go 1.20+ workspace ([instructions](https://go.dev/doc/install)), then: ``` go install github.com/essentialkaos/redis-cli-monitor@latest ``` -#### From [ESSENTIAL KAOS Public Repository](https://yum.kaos.st) +#### From [ESSENTIAL KAOS Public Repository](https://kaos.sh/kaos-repo) ```bash -sudo yum install -y https://yum.kaos.st/kaos-repo-latest.el$(grep 'CPE_NAME' /etc/os-release | tr -d '"' | cut -d':' -f5).noarch.rpm +sudo yum install -y https://pkgs.kaos.st/kaos-repo-latest.el$(grep 'CPE_NAME' /etc/os-release | tr -d '"' | cut -d':' -f5).noarch.rpm sudo yum install redis-cli-monitor ``` @@ -47,32 +47,9 @@ bash <(curl -fsSL https://apps.kaos.st/get) redis-cli-monitor ### Usage -``` -Usage: redis-cli-monitor {options} command-name - -Options - - --host, -h ip/host Server hostname (127.0.0.1 by default) - --port, -p port Server port (6379 by default) - --db, -n db Database number - --raw, -r Print raw data - --password, -a password Password to use when connecting to the server - --timeout, -t 1-300 Connection timeout in seconds (3 by default) - --no-color, -nc Disable colors in output - --help Show this help message - --version, -v Show version - -Examples - - redis-cli-monitor --host 192.168.0.123 --port 6821 --timeout 15 RENAMED_MONITOR - Execute "RENAMED_MONITOR" command on 192.168.0.123:6821 with 15 sec timeout - - redis-cli-monitor -p 6378 -a MySuppaPassword1234 RENAMED_MONITOR - Execute "RENAMED_MONITOR" command on 127.0.0.1:6378 with password "MySuppaPassword1234" - -``` + -### Build Status +### CI Status | Branch | Status | |--------|--------| diff --git a/cli/cli.go b/cli/cli.go index 2ad8c95..ffa19aa 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -22,6 +22,7 @@ import ( "github.com/essentialkaos/ek/v12/strutil" "github.com/essentialkaos/ek/v12/support" "github.com/essentialkaos/ek/v12/support/deps" + "github.com/essentialkaos/ek/v12/terminal" "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/timeutil" "github.com/essentialkaos/ek/v12/usage" @@ -96,11 +97,9 @@ func Run(gitRev string, gomod []byte) { args, errs := options.Parse(optMap) - if len(errs) != 0 { - for _, err := range errs { - printError(err.Error()) - } - + if !errs.IsEmpty() { + terminal.Error("Options parsing errors:") + terminal.Error(errs.String()) os.Exit(1) } @@ -256,14 +255,9 @@ func isDBMatch(cmd, dbNum string) bool { return dbNum == cmd[start+1:end] } -// printError prints error message to console -func printError(f string, a ...interface{}) { - fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...) -} - // printErrorAndExit print error message and exit with exit code 1 func printErrorAndExit(f string, a ...interface{}) { - printError(f, a...) + terminal.Error(f, a...) os.Exit(1) } diff --git a/common/redis-cli-monitor.spec b/common/redis-cli-monitor.spec index 4411bc8..74fb7db 100644 --- a/common/redis-cli-monitor.spec +++ b/common/redis-cli-monitor.spec @@ -6,7 +6,7 @@ Summary: Tiny Redis client for renamed MONITOR commands Name: redis-cli-monitor -Version: 2.2.2 +Version: 2.2.3 Release: 0%{?dist} Group: Applications/System License: Apache License, Version 2.0 @@ -28,14 +28,17 @@ Tiny Redis client for renamed MONITOR commands. ################################################################################ %prep -%setup -q -%build +%setup -q if [[ ! -d "%{name}/vendor" ]] ; then - echo "This package requires vendored dependencies" + echo -e "----\nThis package requires vendored dependencies\n----" + exit 1 +elif [[ -f "%{name}/%{name}" ]] ; then + echo -e "----\nSources must not contain precompiled binaries\n----" exit 1 fi +%build pushd %{name} go build %{name}.go cp LICENSE .. @@ -88,6 +91,10 @@ fi ################################################################################ %changelog +* Sun Jun 23 2024 Anton Novojilov - 2.2.3-0 +- Code refactoring +- Dependencies update + * Thu Mar 28 2024 Anton Novojilov - 2.2.2-0 - Improved support information gathering - Code refactoring diff --git a/go.mod b/go.mod index c5d6516..6023bd1 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,9 @@ module github.com/essentialkaos/redis-cli-monitor go 1.18 -require github.com/essentialkaos/ek/v12 v12.113.1 +require github.com/essentialkaos/ek/v12 v12.127.0 require ( - github.com/essentialkaos/depsy v1.1.0 // indirect - golang.org/x/sys v0.18.0 // indirect + github.com/essentialkaos/depsy v1.3.0 // indirect + golang.org/x/sys v0.21.0 // indirect ) diff --git a/go.sum b/go.sum index efceef3..07ba145 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,10 @@ github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= -github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI= -github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= -github.com/essentialkaos/ek/v12 v12.113.1 h1:3opV9dwRpIQq1fqg5mkaSEt6ogECL4VLzrH/829qeYg= -github.com/essentialkaos/ek/v12 v12.113.1/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= +github.com/essentialkaos/depsy v1.3.0 h1:CN7bRgBU2jGTHSkg/Sh38eDUn7cvmaTp2sxFt2HpFeU= +github.com/essentialkaos/depsy v1.3.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= +github.com/essentialkaos/ek/v12 v12.127.0 h1:fU5A+QbIZ7NTq1K5jGVwAWwuLtBUhsIKuRWYT78hE+Q= +github.com/essentialkaos/ek/v12 v12.127.0/go.mod h1:71IJ7m82hgjrvWnhL+z0vIhguxz47/rfVma5/CeI5Fw= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=