Skip to content

Commit caebc85

Browse files
committed
Code refactoring
1 parent 2da39bf commit caebc85

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

app/app.go

+10-19
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/essentialkaos/ek/v12/options"
1919
"github.com/essentialkaos/ek/v12/support"
2020
"github.com/essentialkaos/ek/v12/support/deps"
21+
"github.com/essentialkaos/ek/v12/terminal"
2122
"github.com/essentialkaos/ek/v12/terminal/tty"
2223
"github.com/essentialkaos/ek/v12/usage"
2324
"github.com/essentialkaos/ek/v12/usage/completion/bash"
@@ -36,7 +37,7 @@ import (
3637
// Basic application info
3738
const (
3839
APP = "Jira Reindex Runner"
39-
VER = "0.0.6"
40+
VER = "0.1.0"
4041
DESC = "Tool for periodical running Jira re-index process"
4142
)
4243

@@ -81,24 +82,19 @@ var optMap = options.Map{
8182
OPT_GENERATE_MAN: {Type: options.BOOL},
8283
}
8384

84-
// useRawOutput is raw output flag (for cli command)
85-
var useRawOutput = false
86-
8785
// ////////////////////////////////////////////////////////////////////////////////// //
8886

8987
// Run is main application function
9088
func Run(gitRev string, gomod []byte) {
9189
preConfigureUI()
9290

93-
runtime.GOMAXPROCS(1)
91+
runtime.GOMAXPROCS(2)
9492

9593
_, errs := options.Parse(optMap)
9694

97-
if len(errs) != 0 {
98-
for _, err := range errs {
99-
printError(err.Error())
100-
}
101-
95+
if !errs.IsEmpty() {
96+
terminal.Error("Options parsing errors:")
97+
terminal.Error(errs.String())
10298
os.Exit(1)
10399
}
104100

@@ -183,10 +179,10 @@ func validateConfig() {
183179
})
184180

185181
if len(errs) != 0 {
186-
printError("Error while configuration file validation:")
182+
terminal.Error("Error while configuration file validation:")
187183

188184
for _, err := range errs {
189-
printError(" %v", err)
185+
terminal.Error(" %v", err)
190186
}
191187

192188
os.Exit(1)
@@ -195,7 +191,7 @@ func validateConfig() {
195191

196192
// setupLogger configures logger subsystems
197193
func setupLogger() {
198-
err := log.Set(knf.GetS(LOG_FILE), knf.GetM(LOG_PERMS, 644))
194+
err := log.Set(knf.GetS(LOG_FILE), knf.GetM(LOG_PERMS, 0644))
199195

200196
if err != nil {
201197
printErrorAndExit(err.Error())
@@ -213,14 +209,9 @@ func process() {
213209
os.Exit(runReindex())
214210
}
215211

216-
// printError prints error message to console
217-
func printError(f string, a ...interface{}) {
218-
fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...)
219-
}
220-
221212
// printErrorAndExit print error message and exit with exit code 1
222213
func printErrorAndExit(f string, a ...interface{}) {
223-
printError(f, a...)
214+
terminal.Error(f, a...)
224215
os.Exit(1)
225216
}
226217

common/jira-reindex-runner.spec

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
Summary: Application for periodical running Jira re-index process
1212
Name: jira-reindex-runner
13-
Version: 0.0.6
13+
Version: 0.1.0
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

@@ -40,7 +40,10 @@ Application for periodical running Jira re-index process.
4040

4141
%build
4242
if [[ ! -d "%{name}/vendor" ]] ; then
43-
echo "This package requires vendored dependencies"
43+
echo -e "----\nThis package requires vendored dependencies\n----"
44+
exit 1
45+
elif [[ -f "%{name}/%{name}" ]] ; then
46+
echo -e "----\nSources must not contain precompiled binaries\n----"
4447
exit 1
4548
fi
4649

@@ -121,6 +124,10 @@ rm -rf %{buildroot}
121124
################################################################################
122125

123126
%changelog
127+
* Sun Jun 23 2024 Anton Novojilov <[email protected]> - 0.1.0-0
128+
- Code refactoring
129+
- Dependencies update
130+
124131
* Thu Mar 28 2024 Anton Novojilov <[email protected]> - 0.0.6-0
125132
- Improved support information gathering
126133
- Code refactoring

0 commit comments

Comments
 (0)