Skip to content

Commit

Permalink
Merge pull request #57 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 0.7.4
  • Loading branch information
andyone authored Feb 15, 2023
2 parents 7ee25b8 + d98de3c commit a331d2d
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 59 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,32 @@ on:
pull_request:
branches: [master]

permissions:
actions: read
contents: read
statuses: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
SRC_DIR: src/github.com/${{ github.repository }}

jobs:
Go:
name: Go
runs-on: ubuntu-latest

env:
SRC_DIR: src/github.com/${{ github.repository }}
GO111MODULE: auto

strategy:
matrix:
go: [ '1.17.x', '1.18.x' ]
go: [ '1.19.x', '1.20.x' ]

steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
id: go

- name: Setup PATH
run: |
echo "GOPATH=${{ github.workspace }}" >> "$GITHUB_ENV"
echo "GOBIN=${{ github.workspace }}/bin" >> "$GITHUB_ENV"
echo "${{ github.workspace }}/bin" >> "$GITHUB_PATH"

- name: Checkout
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
fetch-depth: 2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: go

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
73 changes: 58 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################

# This Makefile generated by GoMakeGen 1.5.1 using next command:
# This Makefile generated by GoMakeGen 2.2.0 using next command:
# gomakegen --mod .
#
# More info: https://kaos.sh/gomakegen
Expand All @@ -9,48 +9,91 @@

export GO111MODULE=on

ifdef VERBOSE ## Print verbose information (Flag)
VERBOSE_FLAG = -v
endif

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 mod-init mod-update mod-vendor help
.PHONY = fmt vet all clean deps update init vendor mod-init mod-update mod-download mod-vendor help

################################################################################

all: knfgen ## Build all binaries

knfgen: ## Build knfgen binary
go build knfgen.go
knfgen:
go build $(VERBOSE_FLAG) -ldflags="-X main.gitrev=$(GITREV)" knfgen.go

install: ## Install all binaries
cp knfgen /usr/bin/knfgen

uninstall: ## Uninstall all binaries
rm -f /usr/bin/knfgen

deps: mod-update ## Download dependencies
init: mod-init ## Initialize new module

mod-init: ## Initialize new module
go mod init
go mod tidy
deps: mod-download ## Download dependencies

update: mod-update ## Update dependencies to the latest versions

mod-update: ## Download modules to local cache
vendor: mod-vendor ## Make vendored copy of dependencies

mod-init:
ifdef MODULE_PATH ## Module path for initialization (String)
go mod init $(MODULE_PATH)
else
go mod init
endif

ifdef COMPAT ## Compatible Go version (String)
go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
else
go mod tidy $(VERBOSE_FLAG)
endif

mod-update:
ifdef UPDATE_ALL ## Update all dependencies (Flag)
go get -u $(VERBOSE_FLAG) all
else
go get -u $(VERBOSE_FLAG) ./...
endif

ifdef COMPAT
go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
else
go mod tidy $(VERBOSE_FLAG)
endif

test -d vendor && rm -rf vendor && go mod vendor $(VERBOSE_FLAG) || :

mod-download:
go mod download

mod-vendor: ## Make vendored copy of dependencies
go mod vendor
mod-vendor:
rm -rf vendor && go mod vendor $(VERBOSE_FLAG)

fmt: ## Format source code with gofmt
find . -name "*.go" -exec gofmt -s -w {} \;

vet: ## Runs go vet over sources
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 ./...

clean: ## Remove generated files
rm -f knfgen

help: ## Show this info
@echo -e '\n\033[1mSupported targets:\033[0m\n'
@echo -e '\n\033[1mTargets:\033[0m\n'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-12s\033[0m %s\n", $$1, $$2}'
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-14s\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}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 1.5.1\033[0m\n'
@echo -e '\033[90mGenerated by GoMakeGen 2.2.0\033[0m\n'

################################################################################
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

<br/>

`KNFGen` is utility for generating Go const code for [KNF](https://pkg.go.dev/pkg.re/essentialkaos/ek.v12@v12.20.4+incompatible/knf) configs.
`knfgen` is utility for generating Go const code for [KNF](https://kaos.sh/knf-spec) configuration files.

### Installation

#### From source

To build the KNFGen from scratch, make sure you have a working Go 1.17+ workspace ([instructions](https://golang.org/doc/install)), then:
To build the `knfgen` from scratch, make sure you have a working Go 1.19+ workspace ([instructions](https://golang.org/doc/install)), then:

```
go install github.com/essentialkaos/knfgen
Expand All @@ -28,7 +28,7 @@ go install github.com/essentialkaos/knfgen

You can download prebuilt binaries for Linux and macOS from [EK Apps Repository](https://apps.kaos.st/knfgen/latest).

To install the latest prebuilt version of knfgen, do:
To install the latest prebuilt version of `knfgen`, do:

```bash
bash <(curl -fsSL https://apps.kaos.st/get) knfgen
Expand All @@ -37,15 +37,19 @@ bash <(curl -fsSL https://apps.kaos.st/get) knfgen
### Usage

```
Usage: knfgen {options} config-file
Options:
--separators, -s Add new lines between sections
--no-color, -nc Disable colors in output
--help, -h Show this help message
--version, -v Show version
Usage: knfgen {options} file
Options
--separators, -s Add new lines between sections
--no-color, -nc Disable colors in output
--help, -h Show this help message
--version, -v Show version
Examples
knfgen app.knf
Generate copy-paste code for app.knf
```

### Build Status
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/essentialkaos/knfgen

go 1.17
go 1.19

require github.com/essentialkaos/ek/v12 v12.43.0
require github.com/essentialkaos/ek/v12 v12.60.0

require golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
require golang.org/x/sys v0.5.0 // indirect
21 changes: 12 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/essentialkaos/check v1.2.1 h1:avvyFy/1acUNwfxwuOLsHeCjfXtMygtbu0lVDr3nxFs=
github.com/essentialkaos/check v1.2.1/go.mod h1:PhxzfJWlf5L/skuyhzBLIvjMB5Xu9TIyDIsqpY5MvB8=
github.com/essentialkaos/ek/v12 v12.43.0 h1:lnwrfGYQFJ3EjEF4ydW2qnshDcXCR2OnNRk0kwlFpFE=
github.com/essentialkaos/ek/v12 v12.43.0/go.mod h1:Cv/tOZshmFg4pMJnBkg4aW/WyYhzzc41qzZIfk5RSi4=
github.com/essentialkaos/go-linenoise/v3 v3.3.5/go.mod h1:g4X3LhT83XT4h7xwrCLclAdMkJvS9qWBQTGNdS6y4vo=
github.com/essentialkaos/check v1.3.0 h1:ria+8o22RCLdt2D/1SHQsEH5Mmy5S+iWHaGHrrbPUc0=
github.com/essentialkaos/check v1.3.0/go.mod h1:PhxzfJWlf5L/skuyhzBLIvjMB5Xu9TIyDIsqpY5MvB8=
github.com/essentialkaos/ek/v12 v12.60.0 h1:Z0wGjnSAyJLHkbhlO27E/GfRqNFD11zPotEha7ygOzg=
github.com/essentialkaos/ek/v12 v12.60.0/go.mod h1:QFEIBoGPE5ezTV08JYWlWLL5t8fwcdOe3/e7bhTJNW0=
github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
14 changes: 7 additions & 7 deletions knfgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2022 ESSENTIAL KAOS //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand All @@ -26,9 +26,9 @@ import (
// ////////////////////////////////////////////////////////////////////////////////// //

const (
APP = "KNFGen"
VER = "0.7.2"
DESC = "Utility for generating Golang const code for KNF configs"
APP = "knfgen"
VER = "0.7.4"
DESC = "Utility for generating Golang const code for KNF configuration files"
)

const (
Expand Down Expand Up @@ -74,7 +74,7 @@ func main() {
return
}

process(args[0])
process(args.Get(0).Clean().String())
}

// configureUI configures user interface
Expand Down Expand Up @@ -190,14 +190,14 @@ func printWarn(f string, a ...interface{}) {

// showUsage shows usage info
func showUsage() {
info := usage.NewInfo("", "config-file")
info := usage.NewInfo("", "file")

info.AddOption(OPT_SEPARATORS, "Add new lines between sections")
info.AddOption(OPT_NO_COLOR, "Disable colors in output")
info.AddOption(OPT_HELP, "Show this help message")
info.AddOption(OPT_VER, "Show version")

info.AddExample("app.conf", "Generate copy-paste code for app.conf")
info.AddExample("app.knf", "Generate copy-paste code for app.knf")

info.Render()
}
Expand Down

0 comments on commit a331d2d

Please sign in to comment.