Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Jun 23, 2024
1 parent 75bc881 commit 27f5d0d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
25 changes: 7 additions & 18 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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"
Expand All @@ -44,7 +45,7 @@ import (
// App info
const (
APP = "Redis Latency Monitor"
VER = "3.2.2"
VER = "3.2.3"
DESC = "Tiny Redis client for latency measurement"
)

Expand Down Expand Up @@ -132,11 +133,9 @@ func Run(gitRev string, gomod []byte) {

_, 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)
}

Expand Down Expand Up @@ -519,15 +518,10 @@ func flushOutput(interval time.Duration) {

// printErrorAndExit print error message and exit from utility
func printErrorAndExit(f string, a ...interface{}) {
printError(f, a...)
terminal.Error(f, a...)
shutdown(1)
}

// printError prints error message to console
func printError(f string, a ...interface{}) {
fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...)
}

// shutdown close connection to Redis and exit from utility
func shutdown(code int) {
if conn != nil {
Expand Down Expand Up @@ -578,12 +572,7 @@ func printCompletion() int {

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

// genUsage generates usage info
Expand Down
15 changes: 11 additions & 4 deletions common/redis-latency-monitor.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Summary: Tiny Redis client for latency measurement
Name: redis-latency-monitor
Version: 3.2.2
Version: 3.2.3
Release: 0%{?dist}
Group: Applications/System
License: Apache License, Version 2.0
Expand All @@ -29,14 +29,17 @@ or connection latency in milliseconds (one thousandth of a second).
################################################################################

%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 ..
Expand Down Expand Up @@ -89,6 +92,10 @@ fi
################################################################################

%changelog
* Sun Jun 23 2024 Anton Novojilov <andy@essentialkaos.com> - 3.2.3-0
- Code refactoring
- Dependencies update

* Thu Mar 28 2024 Anton Novojilov <andy@essentialkaos.com> - 3.2.2-0
- Improved support information gathering
- Code refactoring
Expand Down

0 comments on commit 27f5d0d

Please sign in to comment.