Skip to content

Commit

Permalink
Merge pull request #152 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 1.0.1
  • Loading branch information
andyone authored Jun 24, 2024
2 parents c8c5a8c + 162caf4 commit 7e6df2c
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 114 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ updates:
- "andyone"
reviewers:
- "andyone"
groups:
all:
applies-to: version-updates
update-types:
- "minor"
- "patch"

- package-ecosystem: "github-actions"
directory: "/"
Expand Down
4 changes: 4 additions & 0 deletions .github/images/card.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .github/images/license.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions .github/images/usage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand All @@ -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: .
Expand Down
64 changes: 39 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 "Building yo…"
@go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" yo.go

install: ## Install all binaries
cp yo /usr/bin/yo
@echo "Installing binaries…"
@cp yo /usr/bin/yo

uninstall: ## Uninstall all binaries
rm -f /usr/bin/yo
@echo "Removing installed binaries…"
@rm -f /usr/bin/yo

init: mod-init ## Initialize new module

Expand All @@ -44,57 +45,70 @@ update: mod-update ## Update dependencies to the latest versions
vendor: mod-vendor ## Make vendored copy of dependencies

mod-init:
@echo "[1/2] Modules initialization…"
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 "[2/2] Dependencies cleanup…"
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 "[1/4] Updating dependencies…"
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 "[2/4] Stripping toolchain info…"
@grep -q 'toolchain ' go.mod && go mod edit -toolchain=none || :

@echo "[3/4] Dependencies cleanup…"
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 "[4/4] Updating vendored dependencies…"
@test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :

mod-download:
go mod download
@echo "Downloading dependencies…"
@go mod download

mod-vendor:
rm -rf vendor && go mod vendor $(VERBOSE_FLAG)
@echo "Vendoring dependencies…"
@rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :

fmt: ## Format source code with gofmt
find . -name "*.go" -exec gofmt -s -w {} \;
@echo "Formatting sources…"
@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 "Running 'go vet' over sources…"
@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 "Removing built binaries…"
@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'

################################################################################
67 changes: 13 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<p align="center"><a href="#readme"><img src="https://gh.kaos.st/yo.svg"/></a></p>
<p align="center"><a href="#readme"><img src=".github/images/card.svg"/></a></p>

<p align="center">
<a href="https://github.com/essentialkaos/yo/actions"><img src="https://github.com/essentialkaos/yo/workflows/CI/badge.svg" alt="GitHub Actions Status" /></a>
<a href="https://github.com/essentialkaos/yo/actions?query=workflow%3ACodeQL"><img src="https://github.com/essentialkaos/yo/workflows/CodeQL/badge.svg" /></a>
<a href="https://goreportcard.com/report/github.com/essentialkaos/yo"><img src="https://goreportcard.com/badge/github.com/essentialkaos/yo"></a>
<a href="https://codebeat.co/projects/github-com-essentialkaos-yo-master"><img alt="codebeat badge" src="https://codebeat.co/badges/f9f024b1-a3b2-418f-b3a4-b4f1d0d4c73d" /></a>
<a href="#license"><img src="https://gh.kaos.st/apache2.svg"></a>
<a href="https://kaos.sh/w/yo/ci"><img src="https://kaos.sh/w/yo/ci.svg" alt="GitHub Actions CI Status" /></a>
<a href="https://kaos.sh/w/yo/codeql"><img src="https://kaos.sh/w/yo/codeql.svg" alt="GitHub Actions CodeQL Status" /></a>
<a href="https://kaos.sh/r/yo"><img src="https://kaos.sh/r/yo.svg" alt="GoReportCard" /></a>
<a href="https://kaos.sh/b/yo"><img src="https://kaos.sh/b/f9f024b1-a3b2-418f-b3a4-b4f1d0d4c73d.svg" alt="codebeat badge" /></a>
<a href="#license"><img src=".github/images/license.svg"/></a>
</p>

<p align="center"><a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#build-status">Build Status</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>
<p align="center"><a href="#installation">Installation</a> • <a href="#usage">Usage</a> • <a href="#ci-status">CI Status</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>

<br/>

Expand All @@ -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
Expand All @@ -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
```
<img src=".github/images/usage.svg" />

### 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

Expand Down
Loading

0 comments on commit 7e6df2c

Please sign in to comment.