diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index fc51337..d0ad1de 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -14,6 +14,12 @@ updates:
- "andyone"
reviewers:
- "andyone"
+ groups:
+ all:
+ applies-to: version-updates
+ update-types:
+ - "minor"
+ - "patch"
- package-ecosystem: "github-actions"
directory: "/"
diff --git a/.github/images/card.svg b/.github/images/card.svg
new file mode 100644
index 0000000..1b87d94
--- /dev/null
+++ b/.github/images/card.svg
@@ -0,0 +1,4 @@
+
diff --git a/.github/images/license.svg b/.github/images/license.svg
new file mode 100644
index 0000000..8990e77
--- /dev/null
+++ b/.github/images/license.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/.github/images/usage.svg b/.github/images/usage.svg
new file mode 100644
index 0000000..244f09b
--- /dev/null
+++ b/.github/images/usage.svg
@@ -0,0 +1,109 @@
+
+
diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml
index 758de78..5980e6b 100644
--- a/.github/workflows/docker-push.yml
+++ b/.github/workflows/docker-push.yml
@@ -135,7 +135,7 @@ jobs:
- name: Build and push Docker images (Docker)
if: ${{ steps.build_check.outputs.build == 'true' }}
- uses: docker/build-push-action@v5
+ uses: docker/build-push-action@v6
with:
push: true
context: .
@@ -148,7 +148,7 @@ jobs:
- name: Build and push Docker images (GHCR)
if: ${{ steps.build_check.outputs.build == 'true' }}
- uses: docker/build-push-action@v5
+ uses: docker/build-push-action@v6
with:
push: true
context: .
diff --git a/Makefile b/Makefile
index 26a90b0..23a3b4b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,39 +1,40 @@
################################################################################
-# This Makefile generated by GoMakeGen 2.3.0 using next command:
+# This Makefile generated by GoMakeGen 3.0.2 using next command:
# gomakegen --mod .
#
# More info: https://kaos.sh/gomakegen
################################################################################
-export GO111MODULE=on
-
ifdef VERBOSE ## Print verbose information (Flag)
VERBOSE_FLAG = -v
endif
-COMPAT ?= 1.18
+COMPAT ?= 1.19
MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD)
################################################################################
.DEFAULT_GOAL := help
-.PHONY = fmt vet all clean deps update init vendor mod-init mod-update mod-download mod-vendor help
+.PHONY = fmt vet all install uninstall clean deps update init vendor mod-init mod-update mod-download mod-vendor help
################################################################################
all: yo ## Build all binaries
yo:
- go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" yo.go
+ @echo "[36;1mBuilding yo…[0m"
+ @go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" yo.go
install: ## Install all binaries
- cp yo /usr/bin/yo
+ @echo "[36;1mInstalling binaries…[0m"
+ @cp yo /usr/bin/yo
uninstall: ## Uninstall all binaries
- rm -f /usr/bin/yo
+ @echo "[36;1mRemoving installed binaries…[0m"
+ @rm -f /usr/bin/yo
init: mod-init ## Initialize new module
@@ -44,57 +45,70 @@ update: mod-update ## Update dependencies to the latest versions
vendor: mod-vendor ## Make vendored copy of dependencies
mod-init:
+ @echo "[37m[1/2][0m [36;1mModules initialization…[0m"
ifdef MODULE_PATH ## Module path for initialization (String)
- go mod init $(MODULE_PATH)
+ @go mod init $(MODULE_PATH)
else
- go mod init
+ @go mod init
endif
+ @echo "[37m[2/2][0m [36;1mDependencies cleanup…[0m"
ifdef COMPAT ## Compatible Go version (String)
- go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
+ @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
else
- go mod tidy $(VERBOSE_FLAG)
+ @go mod tidy $(VERBOSE_FLAG)
endif
mod-update:
+ @echo "[37m[1/4][0m [36;1mUpdating dependencies…[0m"
ifdef UPDATE_ALL ## Update all dependencies (Flag)
- go get -u $(VERBOSE_FLAG) all
+ @go get -u $(VERBOSE_FLAG) all
else
- go get -u $(VERBOSE_FLAG) ./...
+ @go get -u $(VERBOSE_FLAG) ./...
endif
+ @echo "[37m[2/4][0m [36;1mStripping toolchain info…[0m"
+ @grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || :
+
+ @echo "[37m[3/4][0m [36;1mDependencies cleanup…[0m"
ifdef COMPAT
- go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
+ @go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
else
- go mod tidy $(VERBOSE_FLAG)
+ @go mod tidy $(VERBOSE_FLAG)
endif
- test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :
+ @echo "[37m[4/4][0m [36;1mUpdating vendored dependencies…[0m"
+ @test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :
mod-download:
- go mod download
+ @echo "[36;1mDownloading dependencies…[0m"
+ @go mod download
mod-vendor:
- rm -rf vendor && go mod vendor $(VERBOSE_FLAG)
+ @echo "[36;1mVendoring dependencies…[0m"
+ @rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :
fmt: ## Format source code with gofmt
- find . -name "*.go" -exec gofmt -s -w {} \;
+ @echo "[36;1mFormatting sources…[0m"
+ @find . -name "*.go" -exec gofmt -s -w {} \;
vet: ## Runs 'go vet' over sources
- go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./...
+ @echo "[36;1mRunning 'go vet' over sources…[0m"
+ @go vet -composites=false -printfuncs=LPrintf,TLPrintf,TPrintf,log.Debug,log.Info,log.Warn,log.Error,log.Critical,log.Print ./...
clean: ## Remove generated files
- rm -f yo
+ @echo "[36;1mRemoving built binaries…[0m"
+ @rm -f yo
help: ## Show this info
@echo -e '\n\033[1mTargets:\033[0m\n'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
- | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-14s\033[0m %s\n", $$1, $$2}'
+ | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-9s\033[0m %s\n", $$1, $$2}'
@echo -e '\n\033[1mVariables:\033[0m\n'
@grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \
| sed 's/ifdef //' \
- | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}'
+ | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-11s\033[0m %s\n", $$1, $$2}'
@echo -e ''
- @echo -e '\033[90mGenerated by GoMakeGen 2.3.0\033[0m\n'
+ @echo -e '\033[90mGenerated by GoMakeGen 3.0.2\033[0m\n'
################################################################################
diff --git a/README.md b/README.md
index ce4429e..226d2b5 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,14 @@
-
+
-
-
-
-
-
+
+
+
+
+
-Installation • Usage • Build Status • Contributing • License
+Installation • Usage • CI Status • Contributing • License
@@ -18,13 +18,13 @@ Yo is a command-line YAML processor.
#### From source
-To build the Yo from scratch, make sure you have a working Go 1.19+ workspace (_[instructions](https://go.dev/doc/install)_), then:
+To build the Yo from scratch, make sure you have a working Go 1.21+ workspace (_[instructions](https://go.dev/doc/install)_), then:
```
go install github.com/essentialkaos/yo@latest
```
-#### From [ESSENTIAL KAOS Public Repository](https://pkgs.kaos.st)
+#### From [ESSENTIAL KAOS Public Repository](https://kaos.sh/kaos-repo)
```bash
sudo yum install -y https://pkgs.kaos.st/kaos-repo-latest.el$(grep 'CPE_NAME' /etc/os-release | tr -d '"' | cut -d':' -f5).noarch.rpm
@@ -41,55 +41,14 @@ bash <(curl -fsSL https://apps.kaos.st/get) yo
### Usage
-```
-Usage: yo {options} query
-
-Options
-
- --from-file, -f filename Read data from file
- --no-color, -nc Disable colors in output
- --help, -h Show this help message
- --version, -v Show version
-
-Examples
-
- cat file.yml | yo '.foo'
- Return value for key foo
-
- yo -f file.yml '.foo'
- Return value for key foo
-
- yo -f file.yml '.foo | length'
- Print value length
-
- yo -f file.yml '.foo[]'
- Return all items from array
-
- yo -f file.yml '.bar[2:]'
- Return subarray started from item with index 2
-
- yo -f file.yml '.bar[1,2,5]'
- Return items with index 1, 2 and 5 from array
-
- yo -f file.yml '.bar[] | length'
- Print array size
-
- yo -f file.yml '.xyz | keys'
- Print hash map keys
-
- yo -f file.yml '.xyz | keys | length'
- Print number of hash map keys
-
- yo -f file.yml '.xyz | keys | sort'
- Print sorted list of keys
-```
+
-### Build Status
+### CI Status
| Branch | Status |
|--------|--------|
-| `master` | [![CI](https://github.com/essentialkaos/yo/workflows/CI/badge.svg?branch=master)](https://github.com/essentialkaos/yo/actions) |
-| `develop` | [![CI](https://github.com/essentialkaos/yo/workflows/CI/badge.svg?branch=develop)](https://github.com/essentialkaos/yo/actions) |
+| `master` | [![CI](https://kaos.sh/w/yo/ci.svg?branch=master)](https://kaos.sh/w/yo/ci?query=branch:master) |
+| `develop` | [![CI](https://kaos.sh/w/yo/ci.svg?branch=develop)](https://kaos.sh/w/yo/ci?query=branch:develop) |
### Contributing
diff --git a/cli/cli.go b/cli/cli.go
index 8bf8bc2..1d6401b 100644
--- a/cli/cli.go
+++ b/cli/cli.go
@@ -18,6 +18,7 @@ import (
"github.com/essentialkaos/ek/v12/options"
"github.com/essentialkaos/ek/v12/support"
"github.com/essentialkaos/ek/v12/support/deps"
+ "github.com/essentialkaos/ek/v12/terminal"
"github.com/essentialkaos/ek/v12/terminal/tty"
"github.com/essentialkaos/ek/v12/usage"
"github.com/essentialkaos/ek/v12/usage/completion/bash"
@@ -33,7 +34,7 @@ import (
const (
APP = "Yo"
- VER = "1.0.0"
+ VER = "1.0.1"
DESC = "Command-line YAML processor"
)
@@ -94,8 +95,9 @@ func Run(gitRev string, gomod []byte) {
args, errs := options.Parse(optMap)
- if len(errs) != 0 {
- printError(errs[0].Error())
+ if !errs.IsEmpty() {
+ terminal.Error("Options parsing errors:")
+ terminal.Error(errs.String())
os.Exit(1)
}
@@ -170,14 +172,14 @@ func process(query string) {
data, err := readData()
if err != nil {
- printError(err.Error())
+ terminal.Error(err)
os.Exit(1)
}
yaml, err := simpleyaml.NewYaml(data)
if err != nil {
- printError(err.Error())
+ terminal.Error(err)
os.Exit(1)
}
@@ -307,7 +309,7 @@ func processData(processor []string, data []*simpleyaml.Yaml) {
case "sort":
result = processorFuncSort(result)
default:
- printError("Unknown function \"%s\"", pf)
+ terminal.Error("Unknown function \"%s\"", pf)
os.Exit(1)
}
}
@@ -543,11 +545,6 @@ func encodeYaml(yaml *simpleyaml.Yaml) {
fmt.Println(string(data[:len(data)-1]))
}
-// printError prints error message to console
-func printError(f string, a ...interface{}) {
- fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...)
-}
-
// ////////////////////////////////////////////////////////////////////////////////// //
// IsArrayToken returns true if it array selector token
@@ -581,12 +578,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
diff --git a/common/yo.spec b/common/yo.spec
index a4744e4..b5d5d1a 100644
--- a/common/yo.spec
+++ b/common/yo.spec
@@ -6,7 +6,7 @@
Summary: Command-line YAML processor
Name: yo
-Version: 1.0.0
+Version: 1.0.1
Release: 0%{?dist}
Group: Applications/System
License: Apache License, Version 2.0
@@ -28,14 +28,17 @@ Command-line YAML processor.
################################################################################
%prep
-%setup -q
-%build
+%setup -q
if [[ ! -d "%{name}/vendor" ]] ; then
- echo "This package requires vendored dependencies"
+ echo -e "----\nThis package requires vendored dependencies\n----"
+ exit 1
+elif [[ -f "%{name}/%{name}" ]] ; then
+ echo -e "----\nSources must not contain precompiled binaries\n----"
exit 1
fi
+%build
pushd %{name}
go build %{name}.go
cp LICENSE ..
@@ -93,6 +96,10 @@ fi
################################################################################
%changelog
+* Mon Jun 24 2024 Anton Novojilov - 1.0.1-0
+- Code refactoring
+- Dependencies update
+
* Thu Mar 28 2024 Anton Novojilov - 1.0.0-0
- Improved support information gathering
- Code refactoring
diff --git a/go.mod b/go.mod
index c40c24f..fba44ed 100644
--- a/go.mod
+++ b/go.mod
@@ -3,12 +3,12 @@ module github.com/essentialkaos/yo
go 1.19
require (
- github.com/essentialkaos/ek/v12 v12.113.1
- github.com/essentialkaos/go-simpleyaml/v2 v2.1.4
+ github.com/essentialkaos/ek/v12 v12.127.0
+ github.com/essentialkaos/go-simpleyaml/v2 v2.1.5
)
require (
- github.com/essentialkaos/depsy v1.1.0 // indirect
- golang.org/x/sys v0.18.0 // indirect
+ github.com/essentialkaos/depsy v1.3.0 // indirect
+ golang.org/x/sys v0.21.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
diff --git a/go.sum b/go.sum
index b76d7b7..288ddba 100644
--- a/go.sum
+++ b/go.sum
@@ -1,15 +1,15 @@
github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk=
-github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI=
-github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8=
-github.com/essentialkaos/ek/v12 v12.113.1 h1:3opV9dwRpIQq1fqg5mkaSEt6ogECL4VLzrH/829qeYg=
-github.com/essentialkaos/ek/v12 v12.113.1/go.mod h1:SslW97Se34YQKc08Ume2V/8h/HPTgLS1+Iok64cNF/U=
-github.com/essentialkaos/go-simpleyaml/v2 v2.1.4 h1:B2bXdGWaQ6Xy3HTsO2DLBoNV7cbMW3KDmeeOKYLo9z0=
-github.com/essentialkaos/go-simpleyaml/v2 v2.1.4/go.mod h1:pVQTleUBC8xBI9+HnTF38xWBZqANNrmMAzwmUemblJg=
+github.com/essentialkaos/depsy v1.3.0 h1:CN7bRgBU2jGTHSkg/Sh38eDUn7cvmaTp2sxFt2HpFeU=
+github.com/essentialkaos/depsy v1.3.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8=
+github.com/essentialkaos/ek/v12 v12.127.0 h1:fU5A+QbIZ7NTq1K5jGVwAWwuLtBUhsIKuRWYT78hE+Q=
+github.com/essentialkaos/ek/v12 v12.127.0/go.mod h1:71IJ7m82hgjrvWnhL+z0vIhguxz47/rfVma5/CeI5Fw=
+github.com/essentialkaos/go-simpleyaml/v2 v2.1.5 h1:HrFk4JhgBT5pzEkwFW4MqdgsAW4KN7/Um6rTHq1GTJk=
+github.com/essentialkaos/go-simpleyaml/v2 v2.1.5/go.mod h1:m3Ub1npzYSZTgSzW68wUT1ak7p9hOSFvTnyhtwKlvSA=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
-golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
-golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
+golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=