Skip to content

Commit

Permalink
Merge pull request #127 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 1.6.1
  • Loading branch information
andyone authored May 3, 2024
2 parents 953c328 + 60186c1 commit 59a248a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 223 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

strategy:
matrix:
go: [ '1.20.x', '1.21.x' ]
go: [ '1.21.x', '1.22.x' ]

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#### From sources

To build the `deadline` from scratch, make sure you have a working Go 1.19+ workspace (_[instructions](https://go.dev/doc/install)_), then:
To build the `deadline` from scratch, make sure you have a working Go 1.21+ workspace (_[instructions](https://go.dev/doc/install)_), then:

```
go install github.com/essentialkaos/deadline@latest
Expand Down
39 changes: 19 additions & 20 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cli

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Copyright (c) 2024 ESSENTIAL KAOS //
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand All @@ -21,19 +21,20 @@ import (
"github.com/essentialkaos/ek/v12/fmtc"
"github.com/essentialkaos/ek/v12/fsutil"
"github.com/essentialkaos/ek/v12/strutil"
"github.com/essentialkaos/ek/v12/support"
"github.com/essentialkaos/ek/v12/support/deps"
"github.com/essentialkaos/ek/v12/system/process"
"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"

"github.com/essentialkaos/deadline/support"
)

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

const (
APP = "deadline"
VER = "1.6.0"
VER = "1.6.1"
DESC = "Simple utility for controlling application working time"
)

Expand All @@ -45,7 +46,7 @@ const (
)

// ERROR_EXIT_CODE is exit code used as error marker
const ERROR_EXIT_CODE = 99
const ERROR_EXIT_CODE = 255

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

Expand All @@ -56,6 +57,7 @@ type SignalInfo struct {

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

// cmd is passed command
var cmd *exec.Cmd

// colorTagApp contains color tag for app name
Expand All @@ -81,7 +83,10 @@ func Run(gitRev string, gomod []byte) {
genAbout(gitRev).Print()
return
case "-vv", "--verbose-version":
support.Print(APP, VER, gitRev, gomod)
support.Collect(APP, VER).
WithRevision(gitRev).
WithDeps(deps.Extract(gomod)).
Print()
return
}
}
Expand Down Expand Up @@ -140,7 +145,7 @@ func parseArgs(args []string) (SignalInfo, string, []string) {
sigInfo, err = parseTimeAndSignal(args[1])

if err != nil {
printError(err.Error())
terminal.Error(err)
os.Exit(ERROR_EXIT_CODE)
}

Expand All @@ -151,7 +156,7 @@ func parseArgs(args []string) (SignalInfo, string, []string) {
}

if !fsutil.CheckPerms("FX", cmdApp) {
printError("Can't execute command %q", args[2])
terminal.Error("Can't execute command %q", args[2])
os.Exit(ERROR_EXIT_CODE)
}

Expand Down Expand Up @@ -241,13 +246,13 @@ func parseTimeAndSignal(data string) (SignalInfo, error) {
return SignalInfo{wait, syscall.SIGTERM}, nil
}

wait, err = timeutil.ParseDuration(strutil.ReadField(data, 0, true, ":"))
wait, err = timeutil.ParseDuration(strutil.ReadField(data, 0, true, ':'))

if err != nil {
return SignalInfo{}, fmt.Errorf("Can't parse %q", data)
}

signal := strutil.ReadField(data, 1, true, ":")
signal := strutil.ReadField(data, 1, true, ':')

switch strings.ToUpper(signal) {
case "SIGABRT", "ABRT", "6":
Expand Down Expand Up @@ -319,16 +324,6 @@ func parseTimeAndSignal(data string) (SignalInfo, error) {
return SignalInfo{wait, sig}, nil
}

// printError prints error message to stderr
func printError(message string, args ...interface{}) {
switch len(args) {
case 0:
fmt.Fprintf(os.Stderr, "%s\n", message)
case 1:
fmt.Fprintf(os.Stderr, "%s\n", fmt.Sprintf(message, args...))
}
}

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

// genUsage generates usage info
Expand Down Expand Up @@ -367,5 +362,9 @@ func genAbout(gitRev string) *usage.About {
License: "Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>",
}

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

return about
}
9 changes: 7 additions & 2 deletions common/deadline.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Summary: Simple utility for controlling application working time
Name: deadline
Version: 1.6.0
Version: 1.6.1
Release: 0%{?dist}
Group: Applications/System
License: Apache 2.0
Expand All @@ -16,7 +16,7 @@ Source0: https://source.kaos.st/%{name}/%{name}-%{version}.tar.bz2

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires: golang >= 1.20
BuildRequires: golang >= 1.21

Provides: %{name} = %{version}-%{release}

Expand Down Expand Up @@ -60,6 +60,11 @@ rm -rf %{buildroot}
################################################################################

%changelog
* Fri May 03 2024 Anton Novojilov <[email protected]> - 1.6.1-0
- Improved support information gathering
- Code refactoring
- Dependencies update

* Thu Jan 11 2024 Anton Novojilov <[email protected]> - 1.6.0-0
- Code refactoring
- Dependencies update
Expand Down
2 changes: 1 addition & 1 deletion deadline.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package main

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Copyright (c) 2024 ESSENTIAL KAOS //
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/essentialkaos/deadline
go 1.18

require (
github.com/essentialkaos/depsy v1.1.0
github.com/essentialkaos/ek/v12 v12.93.0
github.com/essentialkaos/depsy v1.3.0
github.com/essentialkaos/ek/v12 v12.121.0
)

require golang.org/x/sys v0.16.0 // indirect
require golang.org/x/sys v0.19.0 // indirect
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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.93.0 h1:5lwuNYgUYjQHy2h57adWt2t1w5L2MxqTPKgHjyH3h6k=
github.com/essentialkaos/ek/v12 v12.93.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo=
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.121.0 h1:Ax/6FsF6mYzT9KSaphqGqrphvMuWslSCIUCrQqWk0v0=
github.com/essentialkaos/ek/v12 v12.121.0/go.mod h1:VUiC4T8afqtE+UzJftTlIypDBKI1s+0nxxNfBhjyIbo=
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.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
189 changes: 0 additions & 189 deletions support/support.go

This file was deleted.

0 comments on commit 59a248a

Please sign in to comment.