From 496a4162e6c9fe24f9708848170f7b83ae557a78 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 03:23:36 +0000 Subject: [PATCH 01/25] Bump github.com/essentialkaos/ek/v12 from 12.92.0 to 12.93.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.92.0 to 12.93.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.92.0...v12.93.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 721c58b..4e29e1c 100644 --- a/go.mod +++ b/go.mod @@ -4,10 +4,10 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.92.0 + github.com/essentialkaos/ek/v12 v12.93.0 ) require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/sys v0.16.0 // indirect ) diff --git a/go.sum b/go.sum index 514d8df..ff777b2 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,12 @@ 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.92.0 h1:3JIkHWNA6MNkJOfqzMWJ8jN9sRM7nRi7URoFRVFHZzI= -github.com/essentialkaos/ek/v12 v12.92.0/go.mod h1:9efMqo1S8EtYhmeelOSTmMQDGC2vRgPkjkKKfvUD2eU= +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/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= 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.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From 3776ecb1cafc700d420025bb991a5ebcf990a480 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 03:35:08 +0000 Subject: [PATCH 02/25] Bump github.com/essentialkaos/ek/v12 from 12.93.0 to 12.94.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.93.0 to 12.94.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.93.0...v12.94.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4e29e1c..d4080b6 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.93.0 + github.com/essentialkaos/ek/v12 v12.94.0 ) require ( diff --git a/go.sum b/go.sum index ff777b2..1a758e9 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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/ek/v12 v12.94.0 h1:3mPRCOsJKictpqOuydZ0HleCQb/3B3STFo8GJ4yjFOM= +github.com/essentialkaos/ek/v12 v12.94.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From f16e9386d59a4b2896a1c501892e8de348c6611b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Jan 2024 03:41:25 +0000 Subject: [PATCH 03/25] Bump github.com/essentialkaos/ek/v12 from 12.94.0 to 12.95.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.94.0 to 12.95.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.94.0...v12.95.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d4080b6..9019374 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.94.0 + github.com/essentialkaos/ek/v12 v12.95.0 ) require ( diff --git a/go.sum b/go.sum index 1a758e9..da057c2 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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.94.0 h1:3mPRCOsJKictpqOuydZ0HleCQb/3B3STFo8GJ4yjFOM= -github.com/essentialkaos/ek/v12 v12.94.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= +github.com/essentialkaos/ek/v12 v12.95.0 h1:41SOzP03VDDJdFvnxXHKwSuODz2ia39LBjxrKf3Dd1U= +github.com/essentialkaos/ek/v12 v12.95.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From bb9511f646014bb4256546a4d1d81a3d9cdb33d9 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sat, 20 Jan 2024 18:14:28 +0300 Subject: [PATCH 04/25] Update copyright header --- app/app.go | 2 +- app/templates.go | 2 +- scratch.go | 2 +- templates/app/_name_.go | 2 +- templates/app/app/app.go | 2 +- templates/app/app/support/support.go | 2 +- templates/app/app/support/support_darwin.go | 2 +- templates/app/app/support/support_linux.go | 2 +- templates/go-package/_name_.go | 2 +- templates/go-package/_name__test.go | 2 +- templates/package/_name_.go | 2 +- templates/package/_name__test.go | 2 +- templates/service/_name_.go | 2 +- templates/service/daemon/daemon.go | 2 +- templates/service/daemon/support/support.go | 2 +- templates/service/daemon/support/support_linux.go | 2 +- templates/simple-utility/_name_.go | 2 +- templates/utility/_name_.go | 2 +- templates/utility/cli/cli.go | 2 +- templates/utility/cli/support/support.go | 2 +- templates/utility/cli/support/support_darwin.go | 2 +- templates/utility/cli/support/support_linux.go | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/app.go b/app/app.go index 69a0104..5cf4d46 100644 --- a/app/app.go +++ b/app/app.go @@ -2,7 +2,7 @@ package app // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/app/templates.go b/app/templates.go index 7578674..1f9e5f1 100644 --- a/app/templates.go +++ b/app/templates.go @@ -2,7 +2,7 @@ package app // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/scratch.go b/scratch.go index 44190e1..8f032f9 100644 --- a/scratch.go +++ b/scratch.go @@ -2,7 +2,7 @@ package main // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/app/_name_.go b/templates/app/_name_.go index 6f432d8..5674f85 100644 --- a/templates/app/_name_.go +++ b/templates/app/_name_.go @@ -2,7 +2,7 @@ package main // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/app/app/app.go b/templates/app/app/app.go index 1fffec7..5262c54 100644 --- a/templates/app/app/app.go +++ b/templates/app/app/app.go @@ -2,7 +2,7 @@ package app // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/app/app/support/support.go b/templates/app/app/support/support.go index 9374af0..e6bc109 100644 --- a/templates/app/app/support/support.go +++ b/templates/app/app/support/support.go @@ -2,7 +2,7 @@ package support // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/app/app/support/support_darwin.go b/templates/app/app/support/support_darwin.go index 8d1c69b..024612e 100644 --- a/templates/app/app/support/support_darwin.go +++ b/templates/app/app/support/support_darwin.go @@ -2,7 +2,7 @@ package support // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/app/app/support/support_linux.go b/templates/app/app/support/support_linux.go index a3172a7..0c4f719 100644 --- a/templates/app/app/support/support_linux.go +++ b/templates/app/app/support/support_linux.go @@ -2,7 +2,7 @@ package support // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/go-package/_name_.go b/templates/go-package/_name_.go index 0f2cb03..ad9bf8a 100644 --- a/templates/go-package/_name_.go +++ b/templates/go-package/_name_.go @@ -2,7 +2,7 @@ package {{SHORT_NAME}} // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/go-package/_name__test.go b/templates/go-package/_name__test.go index 97e4768..8600d71 100644 --- a/templates/go-package/_name__test.go +++ b/templates/go-package/_name__test.go @@ -2,7 +2,7 @@ package {{SHORT_NAME}} // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/package/_name_.go b/templates/package/_name_.go index 0f2cb03..ad9bf8a 100644 --- a/templates/package/_name_.go +++ b/templates/package/_name_.go @@ -2,7 +2,7 @@ package {{SHORT_NAME}} // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/package/_name__test.go b/templates/package/_name__test.go index 97e4768..8600d71 100644 --- a/templates/package/_name__test.go +++ b/templates/package/_name__test.go @@ -2,7 +2,7 @@ package {{SHORT_NAME}} // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/service/_name_.go b/templates/service/_name_.go index 5c0d67f..141c1b1 100644 --- a/templates/service/_name_.go +++ b/templates/service/_name_.go @@ -2,7 +2,7 @@ package main // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/service/daemon/daemon.go b/templates/service/daemon/daemon.go index 7c17718..3ba8e8e 100644 --- a/templates/service/daemon/daemon.go +++ b/templates/service/daemon/daemon.go @@ -2,7 +2,7 @@ package daemon // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/service/daemon/support/support.go b/templates/service/daemon/support/support.go index 9374af0..e6bc109 100644 --- a/templates/service/daemon/support/support.go +++ b/templates/service/daemon/support/support.go @@ -2,7 +2,7 @@ package support // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/service/daemon/support/support_linux.go b/templates/service/daemon/support/support_linux.go index a3172a7..0c4f719 100644 --- a/templates/service/daemon/support/support_linux.go +++ b/templates/service/daemon/support/support_linux.go @@ -2,7 +2,7 @@ package support // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/simple-utility/_name_.go b/templates/simple-utility/_name_.go index aeb8ee5..eb9a263 100644 --- a/templates/simple-utility/_name_.go +++ b/templates/simple-utility/_name_.go @@ -2,7 +2,7 @@ package main // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/utility/_name_.go b/templates/utility/_name_.go index b3387bc..35ee93f 100644 --- a/templates/utility/_name_.go +++ b/templates/utility/_name_.go @@ -2,7 +2,7 @@ package main // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/utility/cli/cli.go b/templates/utility/cli/cli.go index f3b43a9..a72b19b 100644 --- a/templates/utility/cli/cli.go +++ b/templates/utility/cli/cli.go @@ -2,7 +2,7 @@ package app // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/utility/cli/support/support.go b/templates/utility/cli/support/support.go index 9374af0..e6bc109 100644 --- a/templates/utility/cli/support/support.go +++ b/templates/utility/cli/support/support.go @@ -2,7 +2,7 @@ package support // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/utility/cli/support/support_darwin.go b/templates/utility/cli/support/support_darwin.go index 8d1c69b..024612e 100644 --- a/templates/utility/cli/support/support_darwin.go +++ b/templates/utility/cli/support/support_darwin.go @@ -2,7 +2,7 @@ package support // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/templates/utility/cli/support/support_linux.go b/templates/utility/cli/support/support_linux.go index a3172a7..0c4f719 100644 --- a/templates/utility/cli/support/support_linux.go +++ b/templates/utility/cli/support/support_linux.go @@ -2,7 +2,7 @@ package support // ////////////////////////////////////////////////////////////////////////////////// // // // -// Copyright (c) 2023 ESSENTIAL KAOS // +// Copyright (c) 2024 ESSENTIAL KAOS // // Apache License, Version 2.0 // // // // ////////////////////////////////////////////////////////////////////////////////// // From e66481500947f8e85ddfd4fb36b657f41541fbfc Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sat, 20 Jan 2024 18:17:57 +0300 Subject: [PATCH 05/25] Improve templates --- templates/app/app/app.go | 23 ++--------------------- templates/service/daemon/daemon.go | 21 ++------------------- templates/simple-utility/_name_.go | 23 ++--------------------- templates/utility/cli/cli.go | 23 ++--------------------- 4 files changed, 8 insertions(+), 82 deletions(-) diff --git a/templates/app/app/app.go b/templates/app/app/app.go index 5262c54..c38d31d 100644 --- a/templates/app/app/app.go +++ b/templates/app/app/app.go @@ -10,13 +10,12 @@ package app import ( "fmt" "os" - "strings" "github.com/essentialkaos/ek/v12/fmtc" - "github.com/essentialkaos/ek/v12/fsutil" "github.com/essentialkaos/ek/v12/knf" "github.com/essentialkaos/ek/v12/log" "github.com/essentialkaos/ek/v12/options" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/usage" "github.com/essentialkaos/ek/v12/usage/completion/bash" "github.com/essentialkaos/ek/v12/usage/completion/fish" @@ -127,25 +126,7 @@ func Run(gitRev string, gomod []byte) { // 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 - } - } - - if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" { - fmtc.DisableColors = true - useRawOutput = true - } - - if os.Getenv("NO_COLOR") != "" { + if !tty.IsTTY() { fmtc.DisableColors = true } } diff --git a/templates/service/daemon/daemon.go b/templates/service/daemon/daemon.go index 3ba8e8e..e8fbfa9 100644 --- a/templates/service/daemon/daemon.go +++ b/templates/service/daemon/daemon.go @@ -13,11 +13,11 @@ import ( "strings" "github.com/essentialkaos/ek/v12/fmtc" - "github.com/essentialkaos/ek/v12/fsutil" "github.com/essentialkaos/ek/v12/knf" "github.com/essentialkaos/ek/v12/log" "github.com/essentialkaos/ek/v12/options" "github.com/essentialkaos/ek/v12/signal" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/usage" knfv "github.com/essentialkaos/ek/v12/knf/validators" @@ -114,24 +114,7 @@ func Run(gitRev string, gomod []byte) { // 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 - } - } - - if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" { - fmtc.DisableColors = true - } - - if os.Getenv("NO_COLOR") != "" { + if !tty.IsTTY() { fmtc.DisableColors = true } } diff --git a/templates/simple-utility/_name_.go b/templates/simple-utility/_name_.go index eb9a263..9eda203 100644 --- a/templates/simple-utility/_name_.go +++ b/templates/simple-utility/_name_.go @@ -10,11 +10,10 @@ package main import ( "fmt" "os" - "strings" "github.com/essentialkaos/ek/v12/fmtc" - "github.com/essentialkaos/ek/v12/fsutil" "github.com/essentialkaos/ek/v12/options" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/usage" "github.com/essentialkaos/ek/v12/usage/completion/bash" "github.com/essentialkaos/ek/v12/usage/completion/fish" @@ -103,25 +102,7 @@ func main() { // 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 - } - } - - if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" { - fmtc.DisableColors = true - useRawOutput = true - } - - if os.Getenv("NO_COLOR") != "" { + if !tty.IsTTY() { fmtc.DisableColors = true } } diff --git a/templates/utility/cli/cli.go b/templates/utility/cli/cli.go index a72b19b..7a4dc7e 100644 --- a/templates/utility/cli/cli.go +++ b/templates/utility/cli/cli.go @@ -10,11 +10,10 @@ package app import ( "fmt" "os" - "strings" "github.com/essentialkaos/ek/v12/fmtc" - "github.com/essentialkaos/ek/v12/fsutil" "github.com/essentialkaos/ek/v12/options" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/usage" "github.com/essentialkaos/ek/v12/usage/completion/bash" "github.com/essentialkaos/ek/v12/usage/completion/fish" @@ -107,25 +106,7 @@ func Run(gitRev string, gomod []byte) { // 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 - } - } - - if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" { - fmtc.DisableColors = true - useRawOutput = true - } - - if os.Getenv("NO_COLOR") != "" { + if !tty.IsTTY() { fmtc.DisableColors = true } } From 6de8c93b5fefba7202cda7dfa1c91416b0ccfbb6 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sat, 20 Jan 2024 18:20:47 +0300 Subject: [PATCH 06/25] Dependencies update --- go.mod | 5 +---- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 9019374..09b1714 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,7 @@ module github.com/essentialkaos/scratch go 1.18 -require ( - github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.95.0 -) +require github.com/essentialkaos/ek/v12 v12.96.1 require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect diff --git a/go.sum b/go.sum index da057c2..befcc6f 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ 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.95.0 h1:41SOzP03VDDJdFvnxXHKwSuODz2ia39LBjxrKf3Dd1U= -github.com/essentialkaos/ek/v12 v12.95.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= +github.com/essentialkaos/ek/v12 v12.96.1 h1:SJQGETAJYcV88MphxxdRHy9jNGacUeTksBnoMlXy5z0= +github.com/essentialkaos/ek/v12 v12.96.1/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From 88b022c6dd8525a3cea63a189d6d72d6ef0084fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 03:06:44 +0000 Subject: [PATCH 07/25] Bump github.com/essentialkaos/ek/v12 from 12.96.1 to 12.98.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.96.1 to 12.98.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.96.1...v12.98.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 5 ++++- go.sum | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 09b1714..f1581f4 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,10 @@ module github.com/essentialkaos/scratch go 1.18 -require github.com/essentialkaos/ek/v12 v12.96.1 +require ( + github.com/essentialkaos/depsy v1.1.0 + github.com/essentialkaos/ek/v12 v12.98.0 +) require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect diff --git a/go.sum b/go.sum index befcc6f..fabe474 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= -github.com/essentialkaos/ek/v12 v12.96.1 h1:SJQGETAJYcV88MphxxdRHy9jNGacUeTksBnoMlXy5z0= -github.com/essentialkaos/ek/v12 v12.96.1/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= +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.98.0 h1:DSoP84rmUpNFjfuk8HSL04lkNLC8EzBo38IYoZ0O1qc= +github.com/essentialkaos/ek/v12 v12.98.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From d9932543e8d7cea70c2828fb8b095bddd7026a76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 03:37:42 +0000 Subject: [PATCH 08/25] Bump github.com/essentialkaos/ek/v12 from 12.98.0 to 12.99.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.98.0 to 12.99.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.98.0...v12.99.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f1581f4..33e77e3 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.98.0 + github.com/essentialkaos/ek/v12 v12.99.0 ) require ( diff --git a/go.sum b/go.sum index fabe474..d9ac3b0 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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.98.0 h1:DSoP84rmUpNFjfuk8HSL04lkNLC8EzBo38IYoZ0O1qc= -github.com/essentialkaos/ek/v12 v12.98.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= +github.com/essentialkaos/ek/v12 v12.99.0 h1:WobgR9z6j34IsMvt8kwa54mlSBgHV4bZF6/shYZK6N4= +github.com/essentialkaos/ek/v12 v12.99.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From 7e60cc2341daebf1cef2563f74087a112e51f467 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 03:39:37 +0000 Subject: [PATCH 09/25] Bump github.com/essentialkaos/ek/v12 from 12.99.0 to 12.100.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.99.0 to 12.100.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.99.0...v12.100.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 33e77e3..ac5e952 100644 --- a/go.mod +++ b/go.mod @@ -4,10 +4,10 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.99.0 + github.com/essentialkaos/ek/v12 v12.100.0 ) require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/sys v0.17.0 // indirect ) diff --git a/go.sum b/go.sum index d9ac3b0..8aab0b5 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,12 @@ 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.99.0 h1:WobgR9z6j34IsMvt8kwa54mlSBgHV4bZF6/shYZK6N4= -github.com/essentialkaos/ek/v12 v12.99.0/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= +github.com/essentialkaos/ek/v12 v12.100.0 h1:bup8cqsUUXJtKHAgdt2eHjYKBFU/0rPbg/us2H1E46I= +github.com/essentialkaos/ek/v12 v12.100.0/go.mod h1:VjMWDJ1r4HsfBYJuCNDUo4R1lhCgYkFZOMOH0S3W6iM= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= 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.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From f98997b47e5d7b26c100a9109a4f7ef739e0e792 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Feb 2024 03:12:09 +0000 Subject: [PATCH 10/25] Bump github.com/essentialkaos/ek/v12 from 12.100.0 to 12.101.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.100.0 to 12.101.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.100.0...v12.101.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ac5e952..f5a2db7 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.100.0 + github.com/essentialkaos/ek/v12 v12.101.0 ) require ( diff --git a/go.sum b/go.sum index 8aab0b5..d023528 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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.100.0 h1:bup8cqsUUXJtKHAgdt2eHjYKBFU/0rPbg/us2H1E46I= -github.com/essentialkaos/ek/v12 v12.100.0/go.mod h1:VjMWDJ1r4HsfBYJuCNDUo4R1lhCgYkFZOMOH0S3W6iM= +github.com/essentialkaos/ek/v12 v12.101.0 h1:aD0ifGT52QA5MDQPFpv1z8VVE8TQyrQpJDaTEYlXLs4= +github.com/essentialkaos/ek/v12 v12.101.0/go.mod h1:T5RaDwmg6aso4vPfMp9OSk0R5YAjGtkinlxj2kDXUbo= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From 7b8591aec6fab83c70cb3c0ff3f41b40c3139fc7 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sat, 2 Mar 2024 17:03:04 +0300 Subject: [PATCH 11/25] Improve templates --- app/app.go | 2 +- templates/app/.github/workflows/ci.yml | 4 +- templates/app/.gitignore | 2 + templates/app/app/app.go | 44 ++++++++++++------- templates/app/{app => }/support/support.go | 0 .../app/{app => }/support/support_darwin.go | 0 .../app/{app => }/support/support_linux.go | 0 templates/go-package/.github/workflows/ci.yml | 4 +- templates/package/.github/workflows/ci.yml | 4 +- templates/service/.github/workflows/ci.yml | 6 +-- templates/service/.gitignore | 2 + templates/service/daemon/daemon.go | 22 +++++++++- .../service/{daemon => }/support/support.go | 0 .../{daemon => }/support/support_linux.go | 0 .../simple-utility/.github/workflows/ci.yml | 2 +- templates/utility/.github/workflows/ci.yml | 2 +- templates/utility/.gitignore | 2 + templates/utility/cli/cli.go | 44 ++++++++++++------- .../utility/{cli => }/support/support.go | 0 .../{cli => }/support/support_darwin.go | 0 .../{cli => }/support/support_linux.go | 0 21 files changed, 96 insertions(+), 44 deletions(-) create mode 100644 templates/app/.gitignore rename templates/app/{app => }/support/support.go (100%) rename templates/app/{app => }/support/support_darwin.go (100%) rename templates/app/{app => }/support/support_linux.go (100%) create mode 100644 templates/service/.gitignore rename templates/service/{daemon => }/support/support.go (100%) rename templates/service/{daemon => }/support/support_linux.go (100%) create mode 100644 templates/utility/.gitignore rename templates/utility/{cli => }/support/support.go (100%) rename templates/utility/{cli => }/support/support_darwin.go (100%) rename templates/utility/{cli => }/support/support_linux.go (100%) diff --git a/app/app.go b/app/app.go index 5cf4d46..70c1a91 100644 --- a/app/app.go +++ b/app/app.go @@ -34,7 +34,7 @@ import ( const ( APP = "scratch" - VER = "0.1.0" + VER = "0.1.1" DESC = "Utility for generating blank files for apps and services" ) diff --git a/templates/app/.github/workflows/ci.yml b/templates/app/.github/workflows/ci.yml index 037ccd3..68f7427 100644 --- a/templates/app/.github/workflows/ci.yml +++ b/templates/app/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - go: [ '1.20.x', '1.21.x' ] + go: [ '1.21.x', '1.22.x' ] steps: - name: Checkout @@ -57,7 +57,7 @@ jobs: uses: actions/checkout@v4 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} diff --git a/templates/app/.gitignore b/templates/app/.gitignore new file mode 100644 index 0000000..b3f65c8 --- /dev/null +++ b/templates/app/.gitignore @@ -0,0 +1,2 @@ +{{SHORT_NAME}} +vendor diff --git a/templates/app/app/app.go b/templates/app/app/app.go index c38d31d..66358fa 100644 --- a/templates/app/app/app.go +++ b/templates/app/app/app.go @@ -26,7 +26,7 @@ import ( knfv "github.com/essentialkaos/ek/v12/knf/validators" knff "github.com/essentialkaos/ek/v12/knf/validators/fs" - "github.com/essentialkaos/{{SHORT_NAME}}/app/support" + "github.com/essentialkaos/{{SHORT_NAME}}/support" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -77,6 +77,9 @@ var optMap = options.Map{ // useRawOutput is raw output flag var useRawOutput = false +// color tags for app name and version +var colorTagApp, colorTagVer string + // ////////////////////////////////////////////////////////////////////////////////// // // Run is main utility function @@ -128,6 +131,16 @@ func Run(gitRev string, gomod []byte) { func preConfigureUI() { if !tty.IsTTY() { fmtc.DisableColors = true + useRawOutput = true + } + + switch { + case fmtc.IsTrueColorSupported(): + colorTagApp, colorTagVer = "{*}{#00AFFF}", "{#00AFFF}" + case fmtc.Is256ColorsSupported(): + colorTagApp, colorTagVer = "{*}{#39}", "{#39}" + default: + colorTagApp, colorTagVer = "{*}{c}", "{c}" } } @@ -225,11 +238,11 @@ func printCompletion() int { switch options.GetS(OPT_COMPLETION) { case "bash": - fmt.Printf(bash.Generate(info, "{{SHORT_NAME}}")) + fmt.Print(bash.Generate(info, "{{SHORT_NAME}}")) case "fish": - fmt.Printf(fish.Generate(info, "{{SHORT_NAME}}")) + fmt.Print(fish.Generate(info, "{{SHORT_NAME}}")) case "zsh": - fmt.Printf(zsh.Generate(info, optMap, "{{SHORT_NAME}}")) + fmt.Print(zsh.Generate(info, optMap, "{{SHORT_NAME}}")) default: return 1 } @@ -239,12 +252,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 @@ -262,12 +270,18 @@ func genUsage() *usage.Info { // genAbout generates info about version func genAbout(gitRev string) *usage.About { about := &usage.About{ - App: APP, - Version: VER, - Desc: DESC, - Year: 2009, - Owner: "ESSENTIAL KAOS", + App: APP, + Version: VER, + Desc: DESC, + Year: 2009, + Owner: "ESSENTIAL KAOS", + + AppNameColorTag: colorTagApp, + VersionColorTag: colorTagVer, + DescSeparator: "{s}—{!}", + License: "Apache License, Version 2.0 ", + BugTracker: "https://github.com/essentialkaos/{{SHORT_NAME}}/issues", UpdateChecker: usage.UpdateChecker{"essentialkaos/{{SHORT_NAME}}", update.GitHubChecker}, } diff --git a/templates/app/app/support/support.go b/templates/app/support/support.go similarity index 100% rename from templates/app/app/support/support.go rename to templates/app/support/support.go diff --git a/templates/app/app/support/support_darwin.go b/templates/app/support/support_darwin.go similarity index 100% rename from templates/app/app/support/support_darwin.go rename to templates/app/support/support_darwin.go diff --git a/templates/app/app/support/support_linux.go b/templates/app/support/support_linux.go similarity index 100% rename from templates/app/app/support/support_linux.go rename to templates/app/support/support_linux.go diff --git a/templates/go-package/.github/workflows/ci.yml b/templates/go-package/.github/workflows/ci.yml index 8a28b18..46e2189 100644 --- a/templates/go-package/.github/workflows/ci.yml +++ b/templates/go-package/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - go: [ '1.20.x', '1.21.x' ] + go: [ '1.21.x', '1.22.x' ] steps: - name: Checkout @@ -82,7 +82,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.20.x' + go-version: '1.21.x' - name: Check Golang sources with Aligo uses: essentialkaos/aligo-action@v2 diff --git a/templates/package/.github/workflows/ci.yml b/templates/package/.github/workflows/ci.yml index 8a28b18..46e2189 100644 --- a/templates/package/.github/workflows/ci.yml +++ b/templates/package/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - go: [ '1.20.x', '1.21.x' ] + go: [ '1.21.x', '1.22.x' ] steps: - name: Checkout @@ -82,7 +82,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.20.x' + go-version: '1.21.x' - name: Check Golang sources with Aligo uses: essentialkaos/aligo-action@v2 diff --git a/templates/service/.github/workflows/ci.yml b/templates/service/.github/workflows/ci.yml index ef4d086..6ffc522 100644 --- a/templates/service/.github/workflows/ci.yml +++ b/templates/service/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - go: [ '1.20.x', '1.21.x' ] + go: [ '1.21.x', '1.22.x' ] steps: - name: Checkout @@ -59,7 +59,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.20.x' + go-version: '1.21.x' - name: Download dependencies run: make deps @@ -80,7 +80,7 @@ jobs: uses: actions/checkout@v4 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} diff --git a/templates/service/.gitignore b/templates/service/.gitignore new file mode 100644 index 0000000..b3f65c8 --- /dev/null +++ b/templates/service/.gitignore @@ -0,0 +1,2 @@ +{{SHORT_NAME}} +vendor diff --git a/templates/service/daemon/daemon.go b/templates/service/daemon/daemon.go index e8fbfa9..fda070c 100644 --- a/templates/service/daemon/daemon.go +++ b/templates/service/daemon/daemon.go @@ -23,7 +23,7 @@ import ( knfv "github.com/essentialkaos/ek/v12/knf/validators" knff "github.com/essentialkaos/ek/v12/knf/validators/fs" - "github.com/essentialkaos/{{SHORT_NAME}}/daemon/support" + "github.com/essentialkaos/{{SHORT_NAME}}/support" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -65,6 +65,9 @@ var optMap = options.Map{ OPT_VERB_VER: {Type: options.BOOL}, } +// color tags for app name and version +var colorTagApp, colorTagVer string + // ////////////////////////////////////////////////////////////////////////////////// // // Run is main daemon function @@ -117,6 +120,15 @@ func preConfigureUI() { if !tty.IsTTY() { fmtc.DisableColors = true } + + switch { + case fmtc.IsTrueColorSupported(): + colorTagApp, colorTagVer = "{*}{#00AFFF}", "{#00AFFF}" + case fmtc.Is256ColorsSupported(): + colorTagApp, colorTagVer = "{*}{#39}", "{#39}" + default: + colorTagApp, colorTagVer = "{*}{c}", "{c}" + } } // configureUI configures user interface @@ -268,7 +280,13 @@ func genAbout(gitRev string) *usage.About { Desc: DESC, Year: 2009, Owner: "ESSENTIAL KAOS", - License: "Apache License, Version 2.0 ", + + AppNameColorTag: colorTagApp, + VersionColorTag: colorTagVer, + DescSeparator: "{s}—{!}", + + BugTracker: "https://github.com/essentialkaos/{{SHORT_NAME}}/issues", + License: "Apache License, Version 2.0 ", } if gitRev != "" { diff --git a/templates/service/daemon/support/support.go b/templates/service/support/support.go similarity index 100% rename from templates/service/daemon/support/support.go rename to templates/service/support/support.go diff --git a/templates/service/daemon/support/support_linux.go b/templates/service/support/support_linux.go similarity index 100% rename from templates/service/daemon/support/support_linux.go rename to templates/service/support/support_linux.go diff --git a/templates/simple-utility/.github/workflows/ci.yml b/templates/simple-utility/.github/workflows/ci.yml index 354fbac..ced11e4 100644 --- a/templates/simple-utility/.github/workflows/ci.yml +++ b/templates/simple-utility/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - go: [ '1.20.x', '1.21.x' ] + go: [ '1.21.x', '1.22.x' ] steps: - name: Checkout diff --git a/templates/utility/.github/workflows/ci.yml b/templates/utility/.github/workflows/ci.yml index 354fbac..ced11e4 100644 --- a/templates/utility/.github/workflows/ci.yml +++ b/templates/utility/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - go: [ '1.20.x', '1.21.x' ] + go: [ '1.21.x', '1.22.x' ] steps: - name: Checkout diff --git a/templates/utility/.gitignore b/templates/utility/.gitignore new file mode 100644 index 0000000..b3f65c8 --- /dev/null +++ b/templates/utility/.gitignore @@ -0,0 +1,2 @@ +{{SHORT_NAME}} +vendor diff --git a/templates/utility/cli/cli.go b/templates/utility/cli/cli.go index 7a4dc7e..8f5c78f 100644 --- a/templates/utility/cli/cli.go +++ b/templates/utility/cli/cli.go @@ -21,7 +21,7 @@ import ( "github.com/essentialkaos/ek/v12/usage/man" "github.com/essentialkaos/ek/v12/usage/update" - "github.com/essentialkaos/{{SHORT_NAME}}/cli/support" + "github.com/essentialkaos/{{SHORT_NAME}}/support" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -62,6 +62,9 @@ var optMap = options.Map{ // useRawOutput is raw output flag (for cli command) var useRawOutput = false +// color tags for app name and version +var colorTagApp, colorTagVer string + // ////////////////////////////////////////////////////////////////////////////////// // // Run is main utility function @@ -108,6 +111,16 @@ func Run(gitRev string, gomod []byte) { func preConfigureUI() { if !tty.IsTTY() { fmtc.DisableColors = true + useRawOutput = true + } + + switch { + case fmtc.IsTrueColorSupported(): + colorTagApp, colorTagVer = "{*}{#00AFFF}", "{#00AFFF}" + case fmtc.Is256ColorsSupported(): + colorTagApp, colorTagVer = "{*}{#39}", "{#39}" + default: + colorTagApp, colorTagVer = "{*}{c}", "{c}" } } @@ -149,11 +162,11 @@ func printCompletion() int { switch options.GetS(OPT_COMPLETION) { case "bash": - fmt.Printf(bash.Generate(info, "{{SHORT_NAME}}")) + fmt.Print(bash.Generate(info, "{{SHORT_NAME}}")) case "fish": - fmt.Printf(fish.Generate(info, "{{SHORT_NAME}}")) + fmt.Print(fish.Generate(info, "{{SHORT_NAME}}")) case "zsh": - fmt.Printf(zsh.Generate(info, optMap, "{{SHORT_NAME}}")) + fmt.Print(zsh.Generate(info, optMap, "{{SHORT_NAME}}")) default: return 1 } @@ -163,12 +176,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 @@ -185,12 +193,18 @@ func genUsage() *usage.Info { // genAbout generates info about version func genAbout(gitRev string) *usage.About { about := &usage.About{ - App: APP, - Version: VER, - Desc: DESC, - Year: 2009, - Owner: "ESSENTIAL KAOS", + App: APP, + Version: VER, + Desc: DESC, + Year: 2009, + Owner: "ESSENTIAL KAOS", + + AppNameColorTag: colorTagApp, + VersionColorTag: colorTagVer, + DescSeparator: "{s}—{!}", + License: "Apache License, Version 2.0 ", + BugTracker: "https://github.com/essentialkaos/{{SHORT_NAME}}/issues", UpdateChecker: usage.UpdateChecker{"essentialkaos/{{SHORT_NAME}}", update.GitHubChecker}, } diff --git a/templates/utility/cli/support/support.go b/templates/utility/support/support.go similarity index 100% rename from templates/utility/cli/support/support.go rename to templates/utility/support/support.go diff --git a/templates/utility/cli/support/support_darwin.go b/templates/utility/support/support_darwin.go similarity index 100% rename from templates/utility/cli/support/support_darwin.go rename to templates/utility/support/support_darwin.go diff --git a/templates/utility/cli/support/support_linux.go b/templates/utility/support/support_linux.go similarity index 100% rename from templates/utility/cli/support/support_linux.go rename to templates/utility/support/support_linux.go From 2f5c086321f6641b669da0d2b2ec7de878c688b3 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sat, 2 Mar 2024 17:29:10 +0300 Subject: [PATCH 12/25] Code refactoring --- app/app.go | 67 +++++++++++++++++++++++++++++++----------------------- go.mod | 7 ++++-- go.sum | 10 ++++---- scratch.go | 12 +++++++++- 4 files changed, 61 insertions(+), 35 deletions(-) diff --git a/app/app.go b/app/app.go index 70c1a91..1dd2cc4 100644 --- a/app/app.go +++ b/app/app.go @@ -11,7 +11,6 @@ import ( "fmt" "os" "path/filepath" - "strings" "github.com/essentialkaos/ek/v12/fmtc" "github.com/essentialkaos/ek/v12/fmtutil" @@ -22,19 +21,22 @@ import ( "github.com/essentialkaos/ek/v12/pluralize" "github.com/essentialkaos/ek/v12/sortutil" "github.com/essentialkaos/ek/v12/terminal" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/usage" "github.com/essentialkaos/ek/v12/usage/completion/bash" "github.com/essentialkaos/ek/v12/usage/completion/fish" "github.com/essentialkaos/ek/v12/usage/completion/zsh" "github.com/essentialkaos/ek/v12/usage/man" "github.com/essentialkaos/ek/v12/usage/update" + + "github.com/essentialkaos/scratch/support" ) // ////////////////////////////////////////////////////////////////////////////////// // const ( APP = "scratch" - VER = "0.1.1" + VER = "0.2.0" DESC = "Utility for generating blank files for apps and services" ) @@ -45,6 +47,7 @@ const ( OPT_HELP = "h:help" OPT_VER = "v:version" + OPT_VERB_VER = "vv:verbose-version" OPT_COMPLETION = "completion" OPT_GENERATE_MAN = "generate-man" ) @@ -56,14 +59,17 @@ var optMap = options.Map{ OPT_HELP: {Type: options.BOOL}, OPT_VER: {Type: options.MIXED}, + OPT_VERB_VER: {Type: options.BOOL}, OPT_COMPLETION: {}, OPT_GENERATE_MAN: {Type: options.BOOL}, } +var colorTagApp, colorTagVer string + // ////////////////////////////////////////////////////////////////////////////////// // // Run is main utility function -func Run() { +func Run(gitRev string, gomod []byte) { preConfigureUI() args, errs := options.Parse(optMap) @@ -85,7 +91,10 @@ func Run() { printMan() os.Exit(0) case options.GetB(OPT_VER): - genAbout().Print(options.GetS(OPT_VER)) + genAbout(gitRev).Print(options.GetS(OPT_VER)) + os.Exit(0) + case options.GetB(OPT_VERB_VER): + support.Print(APP, VER, gitRev, gomod) os.Exit(0) case options.GetB(OPT_HELP): genUsage().Print() @@ -107,25 +116,17 @@ func Run() { // 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 - } - } - - if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" { + if !tty.IsTTY() { fmtc.DisableColors = true } - if os.Getenv("NO_COLOR") != "" { - fmtc.DisableColors = true + switch { + case fmtc.IsTrueColorSupported(): + colorTagApp, colorTagVer = "{*}{&}{#F4BA33}", "{#F4BA33}" + case fmtc.Is256ColorsSupported(): + colorTagApp, colorTagVer = "{*}{&}{#220}", "{#220}" + default: + colorTagApp, colorTagVer = "{*}{&}{y}", "{y}" } } @@ -363,7 +364,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 @@ -388,15 +389,25 @@ 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, - Desc: DESC, - Year: 2006, - Owner: "ESSENTIAL KAOS", + App: APP, + Version: VER, + Desc: DESC, + Year: 2009, + Owner: "ESSENTIAL KAOS", + + AppNameColorTag: colorTagApp, + VersionColorTag: colorTagVer, + DescSeparator: "{s}—{!}", + License: "Apache License, Version 2.0 ", - UpdateChecker: usage.UpdateChecker{"essentialkaos/" + APP, update.GitHubChecker}, + BugTracker: "https://github.com/essentialkaos/{{SHORT_NAME}}/issues", + UpdateChecker: usage.UpdateChecker{"essentialkaos/{{SHORT_NAME}}", update.GitHubChecker}, + } + + if gitRev != "" { + about.Build = "git:" + gitRev } return about diff --git a/go.mod b/go.mod index 09b1714..f5a2db7 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,12 @@ module github.com/essentialkaos/scratch go 1.18 -require github.com/essentialkaos/ek/v12 v12.96.1 +require ( + github.com/essentialkaos/depsy v1.1.0 + github.com/essentialkaos/ek/v12 v12.101.0 +) require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/sys v0.17.0 // indirect ) diff --git a/go.sum b/go.sum index befcc6f..d023528 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,12 @@ github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= -github.com/essentialkaos/ek/v12 v12.96.1 h1:SJQGETAJYcV88MphxxdRHy9jNGacUeTksBnoMlXy5z0= -github.com/essentialkaos/ek/v12 v12.96.1/go.mod h1:peB5w8zUkRuDs7m/QG5Z2gMmqzSIs2viAmxzzNFIIoo= +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.101.0 h1:aD0ifGT52QA5MDQPFpv1z8VVE8TQyrQpJDaTEYlXLs4= +github.com/essentialkaos/ek/v12 v12.101.0/go.mod h1:T5RaDwmg6aso4vPfMp9OSk0R5YAjGtkinlxj2kDXUbo= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= 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.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/scratch.go b/scratch.go index 8f032f9..01896e0 100644 --- a/scratch.go +++ b/scratch.go @@ -8,11 +8,21 @@ package main // ////////////////////////////////////////////////////////////////////////////////// // import ( + _ "embed" + APP "github.com/essentialkaos/scratch/app" ) // ////////////////////////////////////////////////////////////////////////////////// // +//go:embed go.mod +var gomod []byte + +// gitrev is short hash of the latest git commit +var gitrev string + +// ////////////////////////////////////////////////////////////////////////////////// // + func main() { - APP.Run() + APP.Run(gitrev, gomod) } From 8e1c6c19a1b14ec25cb74e28de30ec6732d0fc07 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sat, 2 Mar 2024 17:29:24 +0300 Subject: [PATCH 13/25] Code refactoring --- support/support.go | 162 ++++++++++++++++++++++++++++++++++++++ support/support_darwin.go | 40 ++++++++++ support/support_linux.go | 63 +++++++++++++++ 3 files changed, 265 insertions(+) create mode 100644 support/support.go create mode 100644 support/support_darwin.go create mode 100644 support/support_linux.go diff --git a/support/support.go b/support/support.go new file mode 100644 index 0000000..b091bbb --- /dev/null +++ b/support/support.go @@ -0,0 +1,162 @@ +package support + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "fmt" + "os" + "os/exec" + "runtime" + "runtime/debug" + "strings" + + "github.com/essentialkaos/ek/v12/fmtc" + "github.com/essentialkaos/ek/v12/fmtutil" + "github.com/essentialkaos/ek/v12/hash" + "github.com/essentialkaos/ek/v12/strutil" + + "github.com/essentialkaos/depsy" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +// Print prints verbose info about application, system, dependencies and +// important environment +func Print(app, ver, gitRev string, gomod []byte) { + fmtutil.SeparatorTitleColorTag = "{s-}" + fmtutil.SeparatorFullscreen = false + fmtutil.SeparatorColorTag = "{s-}" + fmtutil.SeparatorSize = 80 + + showApplicationInfo(app, ver, gitRev) + showOSInfo() + showEnvInfo() + showDepsInfo(gomod) + + fmtutil.Separator(false) +} + +// ////////////////////////////////////////////////////////////////////////////////// // + +// showApplicationInfo shows verbose information about application +func showApplicationInfo(app, ver, gitRev string) { + fmtutil.Separator(false, "APPLICATION INFO") + + printInfo(7, "Name", app) + printInfo(7, "Version", ver) + + printInfo(7, "Go", fmtc.Sprintf( + "%s {s}(%s/%s){!}", + strings.TrimLeft(runtime.Version(), "go"), + runtime.GOOS, runtime.GOARCH, + )) + + if gitRev == "" { + gitRev = extractGitRevFromBuildInfo() + } + + if gitRev != "" { + if !fmtc.DisableColors && fmtc.IsTrueColorSupported() { + printInfo(7, "Git SHA", gitRev+getHashColorBullet(gitRev)) + } else { + printInfo(7, "Git SHA", gitRev) + } + } + + bin, _ := os.Executable() + binSHA := hash.FileHash(bin) + + if binSHA != "" { + binSHA = strutil.Head(binSHA, 7) + if !fmtc.DisableColors && fmtc.IsTrueColorSupported() { + printInfo(7, "Bin SHA", binSHA+getHashColorBullet(binSHA)) + } else { + printInfo(7, "Bin SHA", binSHA) + } + } +} + +// showEnvInfo shows info about environment +func showEnvInfo() { + fmtutil.Separator(false, "ENVIRONMENT") + + cmd := exec.Command("go", "version") + out, err := cmd.Output() + + if err != nil { + printInfo(2, "Go", "") + return + } + + goVer := string(out) + goVer = strutil.ReadField(goVer, 2, false, ' ') + goVer = strutil.Exclude(goVer, "go") + + printInfo(2, "Go", goVer) +} + +// showDepsInfo shows information about all dependencies +func showDepsInfo(gomod []byte) { + deps := depsy.Extract(gomod, false) + + if len(deps) == 0 { + return + } + + fmtutil.Separator(false, "DEPENDENCIES") + + for _, dep := range deps { + if dep.Extra == "" { + fmtc.Printf(" {s}%8s{!} %s\n", dep.Version, dep.Path) + } else { + fmtc.Printf(" {s}%8s{!} %s {s-}(%s){!}\n", dep.Version, dep.Path, dep.Extra) + } + } +} + +// extractGitRevFromBuildInfo extracts git SHA from embedded build info +func extractGitRevFromBuildInfo() string { + info, ok := debug.ReadBuildInfo() + + if !ok { + return "" + } + + for _, s := range info.Settings { + if s.Key == "vcs.revision" && len(s.Value) > 7 { + return s.Value[:7] + } + } + + return "" +} + +// getHashColorBullet return bullet with color from hash +func getHashColorBullet(v string) string { + if len(v) > 6 { + v = strutil.Head(v, 6) + } + + return fmtc.Sprintf(" {#" + strutil.Head(v, 6) + "}● {!}") +} + +// printInfo formats and prints info record +func printInfo(size int, name, value string) { + name += ":" + size++ + + if value == "" { + fm := fmt.Sprintf(" {*}%%-%ds{!} {s-}—{!}\n", size) + fmtc.Printf(fm, name) + } else { + fm := fmt.Sprintf(" {*}%%-%ds{!} %%s\n", size) + fmtc.Printf(fm, name, value) + } +} + +// ////////////////////////////////////////////////////////////////////////////////// // diff --git a/support/support_darwin.go b/support/support_darwin.go new file mode 100644 index 0000000..a5ebda3 --- /dev/null +++ b/support/support_darwin.go @@ -0,0 +1,40 @@ +package support + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "github.com/essentialkaos/ek/v12/fmtutil" + "github.com/essentialkaos/ek/v12/system" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +// showOSInfo shows verbose information about system +func showOSInfo() { + systemInfo, err := system.GetSystemInfo() + + if err != nil { + return + } + + osInfo, err := system.GetOSInfo() + + if err == nil { + fmtutil.Separator(false, "OS INFO") + + printInfo(12, "Name", osInfo.Name) + printInfo(12, "Version", osInfo.VersionID) + printInfo(12, "Build", osInfo.Build) + } + + fmtutil.Separator(false, "SYSTEM INFO") + + printInfo(7, "Name", systemInfo.OS) + printInfo(7, "Arch", systemInfo.Arch) + printInfo(7, "Kernel", systemInfo.Kernel) +} diff --git a/support/support_linux.go b/support/support_linux.go new file mode 100644 index 0000000..4ad1d6b --- /dev/null +++ b/support/support_linux.go @@ -0,0 +1,63 @@ +package support + +// ////////////////////////////////////////////////////////////////////////////////// // +// // +// Copyright (c) 2023 ESSENTIAL KAOS // +// Apache License, Version 2.0 // +// // +// ////////////////////////////////////////////////////////////////////////////////// // + +import ( + "github.com/essentialkaos/ek/v12/fmtc" + "github.com/essentialkaos/ek/v12/fmtutil" + "github.com/essentialkaos/ek/v12/system" + "github.com/essentialkaos/ek/v12/system/container" +) + +// ////////////////////////////////////////////////////////////////////////////////// // + +// showOSInfo shows verbose information about system +func showOSInfo() { + osInfo, err := system.GetOSInfo() + + if err == nil { + fmtutil.Separator(false, "OS INFO") + + printInfo(12, "Name", osInfo.ColoredName()) + printInfo(12, "Pretty Name", osInfo.ColoredPrettyName()) + printInfo(12, "Version", osInfo.Version) + printInfo(12, "ID", osInfo.ID) + printInfo(12, "ID Like", osInfo.IDLike) + printInfo(12, "Version ID", osInfo.VersionID) + printInfo(12, "Version Code", osInfo.VersionCodename) + printInfo(12, "Platform ID", osInfo.PlatformID) + printInfo(12, "CPE", osInfo.CPEName) + } + + systemInfo, err := system.GetSystemInfo() + + if err != nil { + return + } else if osInfo == nil { + fmtutil.Separator(false, "SYSTEM INFO") + printInfo(12, "Name", systemInfo.OS) + } + + printInfo(12, "Arch", systemInfo.Arch) + printInfo(12, "Kernel", systemInfo.Kernel) + + containerEngine := "No" + + switch container.GetEngine() { + case container.DOCKER: + containerEngine = "Yes (Docker)" + case container.PODMAN: + containerEngine = "Yes (Podman)" + case container.LXC: + containerEngine = "Yes (LXC)" + } + + fmtc.NewLine() + + printInfo(12, "Container", containerEngine) +} From 0bd7bedb4add608ab3fda278453940a93b3810af Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sat, 2 Mar 2024 17:31:09 +0300 Subject: [PATCH 14/25] Improve CI workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a5beb0..ecbb1a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: strategy: matrix: - go: [ '1.20.x', '1.21.x' ] + go: [ '1.18.x', '1.19.x', '1.20.x', '1.21.x', '1.22.x' ] steps: - name: Checkout From 07191ba93bc5beef074fd78dc0ee28df38772e60 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sun, 3 Mar 2024 14:28:43 +0300 Subject: [PATCH 15/25] Improve templates --- templates/app/app/app.go | 30 ++++++++---------------- templates/service/daemon/daemon.go | 37 +++++++++++------------------- 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/templates/app/app/app.go b/templates/app/app/app.go index 66358fa..430d1ec 100644 --- a/templates/app/app/app.go +++ b/templates/app/app/app.go @@ -11,6 +11,7 @@ import ( "fmt" "os" + "github.com/essentialkaos/ek/v12/errutil" "github.com/essentialkaos/ek/v12/fmtc" "github.com/essentialkaos/ek/v12/knf" "github.com/essentialkaos/ek/v12/log" @@ -112,12 +113,11 @@ func Run(gitRev string, gomod []byte) { os.Exit(0) } - err := prepare() - - if err != nil { - printError(err.Error()) - os.Exit(1) - } + err := errutil.Chain( + loadConfig, + validateConfig, + setupLogger, + ) err = process(args) @@ -151,24 +151,12 @@ func configureUI() { } } -// prepare prepares application to run -func prepare() error { +// loadConfig loads configuration file +func loadConfig() error { err := knf.Global(options.GetS(OPT_CONFIG)) if err != nil { - return err - } - - err = validateConfig() - - if err != nil { - return err - } - - err = setupLogger() - - if err != nil { - return err + return fmt.Errorf("Can't load configuration: %w", err) } return nil diff --git a/templates/service/daemon/daemon.go b/templates/service/daemon/daemon.go index fda070c..5defa43 100644 --- a/templates/service/daemon/daemon.go +++ b/templates/service/daemon/daemon.go @@ -12,6 +12,7 @@ import ( "os" "strings" + "github.com/essentialkaos/ek/v12/errutil" "github.com/essentialkaos/ek/v12/fmtc" "github.com/essentialkaos/ek/v12/knf" "github.com/essentialkaos/ek/v12/log" @@ -95,12 +96,12 @@ func Run(gitRev string, gomod []byte) { os.Exit(0) } - err := prepare() - - if err != nil { - printError(err.Error()) - os.Exit(1) - } + err := errutil.Chain( + loadConfig, + validateConfig, + registerSignalHandlers, + setupLogger, + ) log.Aux(strings.Repeat("-", 80)) log.Aux("%s %s starting…", APP, VER) @@ -138,26 +139,12 @@ func configureUI() { } } -// prepare prepares application to run -func prepare() error { +// loadConfig loads configuration file +func loadConfig() error { err := knf.Global(options.GetS(OPT_CONFIG)) if err != nil { - return err - } - - err = validateConfig() - - if err != nil { - return err - } - - registerSignalHandlers() - - err = setupLogger() - - if err != nil { - return err + return fmt.Errorf("Can't load configuration: %w", err) } return nil @@ -180,12 +167,14 @@ func validateConfig() error { } // registerSignalHandlers registers signal handlers -func registerSignalHandlers() { +func registerSignalHandlers() error { signal.Handlers{ signal.TERM: termSignalHandler, signal.INT: intSignalHandler, signal.HUP: hupSignalHandler, }.TrackAsync() + + return nil } // setupLogger configures logger subsystem From f95b0a78bf943769cbbefeb37d4cd9a19c0c6d7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 03:56:32 +0000 Subject: [PATCH 16/25] Bump github.com/essentialkaos/ek/v12 from 12.101.0 to 12.102.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.101.0 to 12.102.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.101.0...v12.102.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f5a2db7..06ff280 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.101.0 + github.com/essentialkaos/ek/v12 v12.102.0 ) require ( diff --git a/go.sum b/go.sum index d023528..9894c0b 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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.101.0 h1:aD0ifGT52QA5MDQPFpv1z8VVE8TQyrQpJDaTEYlXLs4= -github.com/essentialkaos/ek/v12 v12.101.0/go.mod h1:T5RaDwmg6aso4vPfMp9OSk0R5YAjGtkinlxj2kDXUbo= +github.com/essentialkaos/ek/v12 v12.102.0 h1:frHp1+iElQUg4CoscVQWuVFY1QZvU0fIqAaV2RtmeP0= +github.com/essentialkaos/ek/v12 v12.102.0/go.mod h1:T5RaDwmg6aso4vPfMp9OSk0R5YAjGtkinlxj2kDXUbo= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From 2930004c6552ba83e2f04f60636dbe17201b0d58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Mar 2024 03:58:40 +0000 Subject: [PATCH 17/25] Bump github.com/essentialkaos/ek/v12 from 12.102.0 to 12.104.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.102.0 to 12.104.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.102.0...v12.104.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 06ff280..af8c6b0 100644 --- a/go.mod +++ b/go.mod @@ -4,10 +4,10 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.102.0 + github.com/essentialkaos/ek/v12 v12.104.0 ) require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect ) diff --git a/go.sum b/go.sum index 9894c0b..c4a0524 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,12 @@ 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.102.0 h1:frHp1+iElQUg4CoscVQWuVFY1QZvU0fIqAaV2RtmeP0= -github.com/essentialkaos/ek/v12 v12.102.0/go.mod h1:T5RaDwmg6aso4vPfMp9OSk0R5YAjGtkinlxj2kDXUbo= +github.com/essentialkaos/ek/v12 v12.104.0 h1:srNIOipfcfqwWoiZKjIuRhbvEBt0UyP5ni13bimU1Iw= +github.com/essentialkaos/ek/v12 v12.104.0/go.mod h1:exBTL3OE3dm4vjHihE4ZhQ3onJq7C8q2r+OTZmpCO6s= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= 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.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From 5885ae950f132826318c833e13e948af4f776a07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 03:22:21 +0000 Subject: [PATCH 18/25] Bump github.com/essentialkaos/ek/v12 from 12.104.0 to 12.107.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.104.0 to 12.107.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.104.0...v12.107.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index af8c6b0..6b35c2a 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.104.0 + github.com/essentialkaos/ek/v12 v12.107.0 ) require ( diff --git a/go.sum b/go.sum index c4a0524..9f4b20f 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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.104.0 h1:srNIOipfcfqwWoiZKjIuRhbvEBt0UyP5ni13bimU1Iw= -github.com/essentialkaos/ek/v12 v12.104.0/go.mod h1:exBTL3OE3dm4vjHihE4ZhQ3onJq7C8q2r+OTZmpCO6s= +github.com/essentialkaos/ek/v12 v12.107.0 h1:wNUuFXJRPb6iGJEBDvU8pOV7l3a5yzUj5gt7ZR29vew= +github.com/essentialkaos/ek/v12 v12.107.0/go.mod h1:exBTL3OE3dm4vjHihE4ZhQ3onJq7C8q2r+OTZmpCO6s= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From c7b6787892894c6c9154342367d8ba46346d67d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 03:17:36 +0000 Subject: [PATCH 19/25] Bump github.com/essentialkaos/ek/v12 from 12.107.0 to 12.108.1 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.107.0 to 12.108.1. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.107.0...v12.108.1) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6b35c2a..9088051 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.107.0 + github.com/essentialkaos/ek/v12 v12.108.1 ) require ( diff --git a/go.sum b/go.sum index 9f4b20f..c923878 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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.107.0 h1:wNUuFXJRPb6iGJEBDvU8pOV7l3a5yzUj5gt7ZR29vew= -github.com/essentialkaos/ek/v12 v12.107.0/go.mod h1:exBTL3OE3dm4vjHihE4ZhQ3onJq7C8q2r+OTZmpCO6s= +github.com/essentialkaos/ek/v12 v12.108.1 h1:izkeMRhUqpFobP5WtLtFhuuL6UdQj5RHDywIna+cbL0= +github.com/essentialkaos/ek/v12 v12.108.1/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From 77050f5783ee89b21c87b35dbaaf64e8d8447d8d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Mar 2024 03:40:48 +0000 Subject: [PATCH 20/25] Bump github.com/essentialkaos/ek/v12 from 12.108.1 to 12.109.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.108.1 to 12.109.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.108.1...v12.109.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9088051..62d0c3d 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.108.1 + github.com/essentialkaos/ek/v12 v12.109.0 ) require ( diff --git a/go.sum b/go.sum index c923878..5ec1dd1 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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.108.1 h1:izkeMRhUqpFobP5WtLtFhuuL6UdQj5RHDywIna+cbL0= -github.com/essentialkaos/ek/v12 v12.108.1/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= +github.com/essentialkaos/ek/v12 v12.109.0 h1:dwFt9G7gqnLYD8SxZUnWTUnfQWrKxGDA6iMBC1+spF8= +github.com/essentialkaos/ek/v12 v12.109.0/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From d8b9ab017e074f2d5a997d80fdbd5fa1bc1dbed9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 03:03:26 +0000 Subject: [PATCH 21/25] Bump github.com/essentialkaos/ek/v12 from 12.109.0 to 12.111.0 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.109.0 to 12.111.0. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.109.0...v12.111.0) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 62d0c3d..95245b2 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.109.0 + github.com/essentialkaos/ek/v12 v12.111.0 ) require ( diff --git a/go.sum b/go.sum index 5ec1dd1..f20064c 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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.109.0 h1:dwFt9G7gqnLYD8SxZUnWTUnfQWrKxGDA6iMBC1+spF8= -github.com/essentialkaos/ek/v12 v12.109.0/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= +github.com/essentialkaos/ek/v12 v12.111.0 h1:rU7bFXY6uPvJE136B41RQMKu0Mg3eXKEMdGy8EpBJsM= +github.com/essentialkaos/ek/v12 v12.111.0/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From 7f3cdd3cbecf68e7373dde7b4d8a2e9741cecee9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 03:45:47 +0000 Subject: [PATCH 22/25] Bump github.com/essentialkaos/ek/v12 from 12.111.0 to 12.111.1 Bumps [github.com/essentialkaos/ek/v12](https://github.com/essentialkaos/ek) from 12.111.0 to 12.111.1. - [Release notes](https://github.com/essentialkaos/ek/releases) - [Changelog](https://github.com/essentialkaos/ek/blob/master/CHANGELOG.md) - [Commits](https://github.com/essentialkaos/ek/compare/v12.111.0...v12.111.1) --- updated-dependencies: - dependency-name: github.com/essentialkaos/ek/v12 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 95245b2..37b57e6 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.111.0 + github.com/essentialkaos/ek/v12 v12.111.1 ) require ( diff --git a/go.sum b/go.sum index f20064c..55ea702 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ 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.111.0 h1:rU7bFXY6uPvJE136B41RQMKu0Mg3eXKEMdGy8EpBJsM= -github.com/essentialkaos/ek/v12 v12.111.0/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= +github.com/essentialkaos/ek/v12 v12.111.1 h1:s9vi+ydPmt1MI/JtABqmfD32j1VMFsZHe/45eAC+XYU= +github.com/essentialkaos/ek/v12 v12.111.1/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= From ce70311d252856898633cc1f350f19872c2eb322 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Wed, 27 Mar 2024 11:27:04 +0300 Subject: [PATCH 23/25] Update spec templates --- templates/app/common/_name_.spec | 2 +- templates/service/common/_name_.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/app/common/_name_.spec b/templates/app/common/_name_.spec index 8e2be6b..65cd8e5 100644 --- a/templates/app/common/_name_.spec +++ b/templates/app/common/_name_.spec @@ -22,7 +22,7 @@ Source100: checksum.sha512 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: golang >= 1.19 +BuildRequires: golang >= 1.21 Provides: %{name} = %{version}-%{release} diff --git a/templates/service/common/_name_.spec b/templates/service/common/_name_.spec index 70d9b77..a5e8dfc 100644 --- a/templates/service/common/_name_.spec +++ b/templates/service/common/_name_.spec @@ -26,7 +26,7 @@ Source100: checksum.sha512 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: golang >= 1.19 +BuildRequires: golang >= 1.21 Requires: systemd From 603e4cf428d906db413cb582993dcf45f84986b9 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Wed, 27 Mar 2024 11:31:05 +0300 Subject: [PATCH 24/25] Dependencies update --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index f5a2db7..37b57e6 100644 --- a/go.mod +++ b/go.mod @@ -4,10 +4,10 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.101.0 + github.com/essentialkaos/ek/v12 v12.111.1 ) require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect ) diff --git a/go.sum b/go.sum index d023528..55ea702 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,12 @@ 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.101.0 h1:aD0ifGT52QA5MDQPFpv1z8VVE8TQyrQpJDaTEYlXLs4= -github.com/essentialkaos/ek/v12 v12.101.0/go.mod h1:T5RaDwmg6aso4vPfMp9OSk0R5YAjGtkinlxj2kDXUbo= +github.com/essentialkaos/ek/v12 v12.111.1 h1:s9vi+ydPmt1MI/JtABqmfD32j1VMFsZHe/45eAC+XYU= +github.com/essentialkaos/ek/v12 v12.111.1/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= 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.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= From 8bed0a753118fe76d56f9991d1e1245eda216feb Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Wed, 27 Mar 2024 11:35:38 +0300 Subject: [PATCH 25/25] Improve support information gathering --- app/app.go | 10 ++- go.mod | 6 +- support/support.go | 162 -------------------------------------- support/support_darwin.go | 40 ---------- support/support_linux.go | 63 --------------- 5 files changed, 9 insertions(+), 272 deletions(-) delete mode 100644 support/support.go delete mode 100644 support/support_darwin.go delete mode 100644 support/support_linux.go diff --git a/app/app.go b/app/app.go index 1dd2cc4..83c5265 100644 --- a/app/app.go +++ b/app/app.go @@ -20,6 +20,9 @@ import ( "github.com/essentialkaos/ek/v12/path" "github.com/essentialkaos/ek/v12/pluralize" "github.com/essentialkaos/ek/v12/sortutil" + "github.com/essentialkaos/ek/v12/support" + "github.com/essentialkaos/ek/v12/support/apps" + "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/usage" @@ -28,8 +31,6 @@ import ( "github.com/essentialkaos/ek/v12/usage/completion/zsh" "github.com/essentialkaos/ek/v12/usage/man" "github.com/essentialkaos/ek/v12/usage/update" - - "github.com/essentialkaos/scratch/support" ) // ////////////////////////////////////////////////////////////////////////////////// // @@ -94,7 +95,10 @@ func Run(gitRev string, gomod []byte) { genAbout(gitRev).Print(options.GetS(OPT_VER)) os.Exit(0) case options.GetB(OPT_VERB_VER): - support.Print(APP, VER, gitRev, gomod) + support.Collect(APP, VER).WithRevision(gitRev). + WithDeps(deps.Extract(gomod)). + WithApps(apps.Golang()).Print() + os.Exit(0) os.Exit(0) case options.GetB(OPT_HELP): genUsage().Print() diff --git a/go.mod b/go.mod index 37b57e6..d39a799 100644 --- a/go.mod +++ b/go.mod @@ -2,12 +2,10 @@ module github.com/essentialkaos/scratch go 1.18 -require ( - github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.111.1 -) +require github.com/essentialkaos/ek/v12 v12.111.1 require ( + github.com/essentialkaos/depsy v1.1.0 // indirect github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect golang.org/x/sys v0.18.0 // indirect ) diff --git a/support/support.go b/support/support.go deleted file mode 100644 index b091bbb..0000000 --- a/support/support.go +++ /dev/null @@ -1,162 +0,0 @@ -package support - -// ////////////////////////////////////////////////////////////////////////////////// // -// // -// Copyright (c) 2023 ESSENTIAL KAOS // -// Apache License, Version 2.0 // -// // -// ////////////////////////////////////////////////////////////////////////////////// // - -import ( - "fmt" - "os" - "os/exec" - "runtime" - "runtime/debug" - "strings" - - "github.com/essentialkaos/ek/v12/fmtc" - "github.com/essentialkaos/ek/v12/fmtutil" - "github.com/essentialkaos/ek/v12/hash" - "github.com/essentialkaos/ek/v12/strutil" - - "github.com/essentialkaos/depsy" -) - -// ////////////////////////////////////////////////////////////////////////////////// // - -// Print prints verbose info about application, system, dependencies and -// important environment -func Print(app, ver, gitRev string, gomod []byte) { - fmtutil.SeparatorTitleColorTag = "{s-}" - fmtutil.SeparatorFullscreen = false - fmtutil.SeparatorColorTag = "{s-}" - fmtutil.SeparatorSize = 80 - - showApplicationInfo(app, ver, gitRev) - showOSInfo() - showEnvInfo() - showDepsInfo(gomod) - - fmtutil.Separator(false) -} - -// ////////////////////////////////////////////////////////////////////////////////// // - -// showApplicationInfo shows verbose information about application -func showApplicationInfo(app, ver, gitRev string) { - fmtutil.Separator(false, "APPLICATION INFO") - - printInfo(7, "Name", app) - printInfo(7, "Version", ver) - - printInfo(7, "Go", fmtc.Sprintf( - "%s {s}(%s/%s){!}", - strings.TrimLeft(runtime.Version(), "go"), - runtime.GOOS, runtime.GOARCH, - )) - - if gitRev == "" { - gitRev = extractGitRevFromBuildInfo() - } - - if gitRev != "" { - if !fmtc.DisableColors && fmtc.IsTrueColorSupported() { - printInfo(7, "Git SHA", gitRev+getHashColorBullet(gitRev)) - } else { - printInfo(7, "Git SHA", gitRev) - } - } - - bin, _ := os.Executable() - binSHA := hash.FileHash(bin) - - if binSHA != "" { - binSHA = strutil.Head(binSHA, 7) - if !fmtc.DisableColors && fmtc.IsTrueColorSupported() { - printInfo(7, "Bin SHA", binSHA+getHashColorBullet(binSHA)) - } else { - printInfo(7, "Bin SHA", binSHA) - } - } -} - -// showEnvInfo shows info about environment -func showEnvInfo() { - fmtutil.Separator(false, "ENVIRONMENT") - - cmd := exec.Command("go", "version") - out, err := cmd.Output() - - if err != nil { - printInfo(2, "Go", "") - return - } - - goVer := string(out) - goVer = strutil.ReadField(goVer, 2, false, ' ') - goVer = strutil.Exclude(goVer, "go") - - printInfo(2, "Go", goVer) -} - -// showDepsInfo shows information about all dependencies -func showDepsInfo(gomod []byte) { - deps := depsy.Extract(gomod, false) - - if len(deps) == 0 { - return - } - - fmtutil.Separator(false, "DEPENDENCIES") - - for _, dep := range deps { - if dep.Extra == "" { - fmtc.Printf(" {s}%8s{!} %s\n", dep.Version, dep.Path) - } else { - fmtc.Printf(" {s}%8s{!} %s {s-}(%s){!}\n", dep.Version, dep.Path, dep.Extra) - } - } -} - -// extractGitRevFromBuildInfo extracts git SHA from embedded build info -func extractGitRevFromBuildInfo() string { - info, ok := debug.ReadBuildInfo() - - if !ok { - return "" - } - - for _, s := range info.Settings { - if s.Key == "vcs.revision" && len(s.Value) > 7 { - return s.Value[:7] - } - } - - return "" -} - -// getHashColorBullet return bullet with color from hash -func getHashColorBullet(v string) string { - if len(v) > 6 { - v = strutil.Head(v, 6) - } - - return fmtc.Sprintf(" {#" + strutil.Head(v, 6) + "}● {!}") -} - -// printInfo formats and prints info record -func printInfo(size int, name, value string) { - name += ":" - size++ - - if value == "" { - fm := fmt.Sprintf(" {*}%%-%ds{!} {s-}—{!}\n", size) - fmtc.Printf(fm, name) - } else { - fm := fmt.Sprintf(" {*}%%-%ds{!} %%s\n", size) - fmtc.Printf(fm, name, value) - } -} - -// ////////////////////////////////////////////////////////////////////////////////// // diff --git a/support/support_darwin.go b/support/support_darwin.go deleted file mode 100644 index a5ebda3..0000000 --- a/support/support_darwin.go +++ /dev/null @@ -1,40 +0,0 @@ -package support - -// ////////////////////////////////////////////////////////////////////////////////// // -// // -// Copyright (c) 2023 ESSENTIAL KAOS // -// Apache License, Version 2.0 // -// // -// ////////////////////////////////////////////////////////////////////////////////// // - -import ( - "github.com/essentialkaos/ek/v12/fmtutil" - "github.com/essentialkaos/ek/v12/system" -) - -// ////////////////////////////////////////////////////////////////////////////////// // - -// showOSInfo shows verbose information about system -func showOSInfo() { - systemInfo, err := system.GetSystemInfo() - - if err != nil { - return - } - - osInfo, err := system.GetOSInfo() - - if err == nil { - fmtutil.Separator(false, "OS INFO") - - printInfo(12, "Name", osInfo.Name) - printInfo(12, "Version", osInfo.VersionID) - printInfo(12, "Build", osInfo.Build) - } - - fmtutil.Separator(false, "SYSTEM INFO") - - printInfo(7, "Name", systemInfo.OS) - printInfo(7, "Arch", systemInfo.Arch) - printInfo(7, "Kernel", systemInfo.Kernel) -} diff --git a/support/support_linux.go b/support/support_linux.go deleted file mode 100644 index 4ad1d6b..0000000 --- a/support/support_linux.go +++ /dev/null @@ -1,63 +0,0 @@ -package support - -// ////////////////////////////////////////////////////////////////////////////////// // -// // -// Copyright (c) 2023 ESSENTIAL KAOS // -// Apache License, Version 2.0 // -// // -// ////////////////////////////////////////////////////////////////////////////////// // - -import ( - "github.com/essentialkaos/ek/v12/fmtc" - "github.com/essentialkaos/ek/v12/fmtutil" - "github.com/essentialkaos/ek/v12/system" - "github.com/essentialkaos/ek/v12/system/container" -) - -// ////////////////////////////////////////////////////////////////////////////////// // - -// showOSInfo shows verbose information about system -func showOSInfo() { - osInfo, err := system.GetOSInfo() - - if err == nil { - fmtutil.Separator(false, "OS INFO") - - printInfo(12, "Name", osInfo.ColoredName()) - printInfo(12, "Pretty Name", osInfo.ColoredPrettyName()) - printInfo(12, "Version", osInfo.Version) - printInfo(12, "ID", osInfo.ID) - printInfo(12, "ID Like", osInfo.IDLike) - printInfo(12, "Version ID", osInfo.VersionID) - printInfo(12, "Version Code", osInfo.VersionCodename) - printInfo(12, "Platform ID", osInfo.PlatformID) - printInfo(12, "CPE", osInfo.CPEName) - } - - systemInfo, err := system.GetSystemInfo() - - if err != nil { - return - } else if osInfo == nil { - fmtutil.Separator(false, "SYSTEM INFO") - printInfo(12, "Name", systemInfo.OS) - } - - printInfo(12, "Arch", systemInfo.Arch) - printInfo(12, "Kernel", systemInfo.Kernel) - - containerEngine := "No" - - switch container.GetEngine() { - case container.DOCKER: - containerEngine = "Yes (Docker)" - case container.PODMAN: - containerEngine = "Yes (Podman)" - case container.LXC: - containerEngine = "Yes (LXC)" - } - - fmtc.NewLine() - - printInfo(12, "Container", containerEngine) -}