Skip to content

Commit

Permalink
Merge pull request #56 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 1.2.0
  • Loading branch information
andyone authored Jan 23, 2023
2 parents b2c211b + 8eb0bd3 commit e8954ef
Show file tree
Hide file tree
Showing 12 changed files with 378 additions and 50 deletions.
4 changes: 1 addition & 3 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ _Before opening an issue, search for similar bug reports or feature requests on

**System info:**

* **Version used (`bop -v`):**
* **OS (e.g. from `/etc/*-release`):**
* **Kernel (`uname -a`):**
* **Verbose version info (`bop -vv`):**
* **Install tools:**

**Steps to reproduce:**
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a href="#license"><img src="https://gh.kaos.st/apache2.svg"></a>
</p>

<p align="center"><a href="#installation">Installation</a> • <a href="#docker-support">Docker support</a> • <a href="#command-line-completion">Command-line completion</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="#docker-support">Docker support</a> • <a href="#command-line-completion">Command-line completion</a> • <a href="#man-documentation">Man documentation</a> • <a href="#usage">Usage</a> • <a href="#build-status">Build Status</a> • <a href="#contributing">Contributing</a> • <a href="#license">License</a></p>

</br>

Expand Down Expand Up @@ -64,6 +64,14 @@ Fish:
sudo bop --completion=fish 1> /usr/share/fish/vendor_completions.d/bop.fish
```

### Man documentation

You can generate man page using next command:

```bash
bop --generate-man | sudo gzip > /usr/share/man/man1/bop.1.gz
```

### Usage

```
Expand All @@ -79,9 +87,14 @@ Options
Examples
bop redis redis*.rpm
Generate tests for Redis package
bop htop htop*.rpm
Generate simple tests for package
bop redis redis*.rpm -s redis
Generate tests with service check
bop -o zl.recipe zlib zlib*.rpm minizip*.rpm
Generate tests with custom name
```

### Build Status
Expand Down
14 changes: 12 additions & 2 deletions bop.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@ 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> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //

import (
_ "embed"

CLI "github.com/essentialkaos/bop/cli"
)

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

//go:embed go.mod
var gomod []byte

// gitrev is short hash of the latest git commit
var gitrev string

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

func main() {
CLI.Init()
CLI.Init(gitrev, gomod)
}
95 changes: 60 additions & 35 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cli

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// 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 @@ -24,19 +24,21 @@ import (
"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/bop/extractor"
"github.com/essentialkaos/bop/generator"
"github.com/essentialkaos/bop/rpm"
"github.com/essentialkaos/bop/support"
)

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

// App info
const (
APP = "bop"
VER = "1.1.6"
VER = "1.2.0"
DESC = "Utility for generating formal bibop tests for RPM packages"
)

Expand All @@ -50,7 +52,9 @@ const (
OPT_HELP = "h:help"
OPT_VER = "v:version"

OPT_COMPLETION = "completion"
OPT_VERB_VER = "vv:verbose-version"
OPT_COMPLETION = "completion"
OPT_GENERATE_MAN = "generate-man"
)

// ////////////////////////////////////////////////////////////////////////////////// //
Expand All @@ -62,13 +66,15 @@ var optMap = options.Map{
OPT_HELP: {Type: options.BOOL, Alias: "u:usage"},
OPT_VER: {Type: options.BOOL, Alias: "ver"},

OPT_COMPLETION: {},
OPT_VERB_VER: {Type: options.BOOL},
OPT_COMPLETION: {},
OPT_GENERATE_MAN: {Type: options.BOOL},
}

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

// Init is main function
func Init() {
func Init(gitRev string, gomod []byte) {
args, errs := options.Parse(optMap)

if len(errs) != 0 {
Expand All @@ -83,16 +89,18 @@ func Init() {
fmtc.DisableColors = true
}

if options.Has(OPT_COMPLETION) {
genCompletion()
}

if options.GetB(OPT_VER) {
showAbout()
switch {
case options.Has(OPT_COMPLETION):
os.Exit(genCompletion())
case options.Has(OPT_GENERATE_MAN):
os.Exit(genMan())
case options.GetB(OPT_VER):
showAbout(gitRev)
return
}

if options.GetB(OPT_HELP) || len(args) < 2 {
case options.GetB(OPT_VERB_VER):
support.ShowSupportInfo(APP, VER, gitRev, gomod)
return
case options.GetB(OPT_HELP) || len(args) < 2:
showUsage()
return
}
Expand Down Expand Up @@ -205,23 +213,13 @@ func showUsage() {
genUsage().Render()
}

// genUsage generates usage info
func genUsage() *usage.Info {
info := usage.NewInfo("", "name", "package…")

info.AddOption(OPT_OUTPUT, "Output file", "file")
info.AddOption(OPT_SERVICE, "List of services for checking {c}(mergable){!}", "service")
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("redis redis*.rpm", "Generate tests for Redis package")

return info
// showAbout prints info about version
func showAbout(gitRev string) {
genAbout(gitRev).Render()
}

// genCompletion generates completion for different shells
func genCompletion() {
func genCompletion() int {
info := genUsage()

switch options.GetS(OPT_COMPLETION) {
Expand All @@ -232,15 +230,44 @@ func genCompletion() {
case "zsh":
fmt.Printf(zsh.Generate(info, optMap, "bop"))
default:
os.Exit(1)
return 1
}

os.Exit(0)
return 0
}

// showAbout prints info about version
func showAbout() {
about := &usage.About{
// genMan generates man page
func genMan() int {
fmt.Println(
man.Generate(
genUsage(),
genAbout(""),
),
)

return 0
}

// genUsage generates usage info
func genUsage() *usage.Info {
info := usage.NewInfo("", "name", "package…")

info.AddOption(OPT_OUTPUT, "Output file", "file")
info.AddOption(OPT_SERVICE, "List of services for checking {c}(mergable){!}", "service")
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("htop htop*.rpm", "Generate simple tests for package")
info.AddExample("redis redis*.rpm -s redis", "Generate tests with service check")
info.AddExample("-o zl.recipe zlib zlib*.rpm minizip*.rpm", "Generate tests with custom name")

return info
}

// genAbout generates info about version
func genAbout(gitRev string) *usage.About {
return &usage.About{
App: APP,
Version: VER,
Desc: DESC,
Expand All @@ -249,6 +276,4 @@ func showAbout() {
License: "Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>",
UpdateChecker: usage.UpdateChecker{"essentialkaos/bop", update.GitHubChecker},
}

about.Render()
}
2 changes: 1 addition & 1 deletion data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package data

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2022 ESSENTIAL KAOS //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
2 changes: 1 addition & 1 deletion extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package extractor

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2022 ESSENTIAL KAOS //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
2 changes: 1 addition & 1 deletion generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package generator

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

go 1.17

require github.com/essentialkaos/ek/v12 v12.57.1
require (
github.com/essentialkaos/depsy v1.0.0
github.com/essentialkaos/ek/v12 v12.57.1
)

require golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
require golang.org/x/sys v0.4.0 // indirect
5 changes: 4 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
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/depsy v1.0.0 h1:FikBtTnNhk+xFO/hFr+CfiKs6QnA3wMD6tGL0XTEUkc=
github.com/essentialkaos/depsy v1.0.0/go.mod h1:XVsB2eVUonEzmLKQP3ig2P6v2+WcHVgJ10zm0JLqFMM=
github.com/essentialkaos/ek/v12 v12.57.1 h1:9dj32HLCVmseBoa43F6HaZz1qbKts5GNBCtFdrpQPno=
github.com/essentialkaos/ek/v12 v12.57.1/go.mod h1:G8ghiSKh8ToJQCdB2bAhE3CnI6dn9nTJdWH3bQIVr1U=
github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI=
Expand All @@ -20,8 +22,9 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
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-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.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
2 changes: 1 addition & 1 deletion rpm/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package rpm

// ////////////////////////////////////////////////////////////////////////////////// //
// //
// Copyright (c) 2022 ESSENTIAL KAOS //
// Copyright (c) 2023 ESSENTIAL KAOS //
// Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0> //
// //
// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
Loading

0 comments on commit e8954ef

Please sign in to comment.