Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.3.0 #51

Merged
merged 48 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
39231f9
Bump golang.org/x/crypto from 0.13.0 to 0.14.0
dependabot[bot] Oct 6, 2023
70ec309
Merge pull request #50 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 6, 2023
a648191
Add '-pi'/'--postpone-index' option to postpone index rebuild after s…
andyone Oct 9, 2023
9dfd31d
Fix payload output
andyone Oct 10, 2023
5e7f402
Bump github.com/essentialkaos/ek/v12 from 12.79.0 to 12.80.0
dependabot[bot] Oct 13, 2023
909db73
Merge pull request #52 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 13, 2023
5b61400
Bump github.com/klauspost/compress from 1.17.0 to 1.17.1
dependabot[bot] Oct 16, 2023
adaa00f
Merge pull request #53 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 16, 2023
519fbc7
Bump github.com/essentialkaos/ek/v12 from 12.80.0 to 12.82.0
dependabot[bot] Oct 17, 2023
c764b2b
Merge pull request #54 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 17, 2023
f920b61
Bump github.com/essentialkaos/ek/v12 from 12.82.0 to 12.83.1
dependabot[bot] Oct 24, 2023
911ae8a
Merge pull request #57 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 25, 2023
8e89524
Bump github.com/klauspost/compress from 1.17.1 to 1.17.2
dependabot[bot] Oct 25, 2023
020c09a
Merge pull request #56 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 25, 2023
9beadad
Bump github.com/essentialkaos/ek/v12 from 12.83.1 to 12.83.2
dependabot[bot] Nov 2, 2023
bf7da8a
Merge pull request #58 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 2, 2023
f31c5b7
Bump github.com/mattn/go-sqlite3 from 1.14.17 to 1.14.18
dependabot[bot] Nov 6, 2023
2470de8
Merge pull request #59 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 6, 2023
4af1125
Bump golang.org/x/crypto from 0.14.0 to 0.15.0
dependabot[bot] Nov 9, 2023
51bdeb7
Merge pull request #60 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 9, 2023
a73f3ef
Improve 'check' command output
andyone Nov 9, 2023
cd1f4c9
Bump github.com/essentialkaos/ek/v12 from 12.83.2 to 12.84.0
dependabot[bot] Nov 14, 2023
8ee24ee
Merge pull request #61 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 14, 2023
82de05d
Bump github.com/essentialkaos/ek/v12 from 12.84.0 to 12.85.0
dependabot[bot] Nov 15, 2023
6c51877
Merge pull request #62 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 15, 2023
68198a0
Bump github.com/klauspost/compress from 1.17.2 to 1.17.3
dependabot[bot] Nov 16, 2023
02fb4e4
Merge pull request #63 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 16, 2023
2708809
Bump github.com/essentialkaos/ek/v12 from 12.85.0 to 12.86.0
dependabot[bot] Nov 17, 2023
52805ce
Merge pull request #64 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 17, 2023
aaea690
Add cleanup filtering
andyone Nov 20, 2023
7eeaeb7
Improve support info
andyone Nov 20, 2023
6922ec2
Improve help content rendering
andyone Nov 20, 2023
4059d57
Improve pager support
andyone Nov 22, 2023
a7e85df
Bump github.com/essentialkaos/ek/v12 from 12.88.1 to 12.90.0
dependabot[bot] Nov 27, 2023
0cbc2cf
Bump golang.org/x/crypto from 0.15.0 to 0.16.0
dependabot[bot] Nov 28, 2023
ce33605
Merge pull request #68 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 29, 2023
c409957
Merge pull request #67 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 29, 2023
be08cc6
Bump github.com/essentialkaos/ek/v12 from 12.90.0 to 12.90.1
dependabot[bot] Dec 4, 2023
bbdb104
Merge pull request #70 from essentialkaos/dependabot/go_modules/devel…
andyone Dec 4, 2023
deda42a
Bump github.com/klauspost/compress from 1.17.3 to 1.17.4
dependabot[bot] Dec 4, 2023
6fa6697
Merge pull request #69 from essentialkaos/dependabot/go_modules/devel…
andyone Dec 4, 2023
bd1d3ef
Code refactoring
andyone Dec 5, 2023
05cfaf0
Code refactoring
andyone Dec 5, 2023
e95cf67
Code refactoring
andyone Dec 5, 2023
a70d979
Update project ID on codeclimate
andyone Dec 5, 2023
a882678
Update README
andyone Dec 5, 2023
12117fa
Minor UI improvements
andyone Dec 5, 2023
fcf2eaf
Spec update
andyone Dec 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<p align="center">
<a href="https://kaos.sh/r/rep"><img src="https://kaos.sh/r/rep.svg" alt="GoReportCard" /></a>
<a href="https://kaos.sh/l/rep"><img src="https://kaos.sh/l/e3f19767174b1fd0777d.svg" alt="Code Climate Maintainability" /></a>
<a href="https://kaos.sh/l/rep"><img src="https://kaos.sh/l/5876fdc611100e9f8a83.svg" alt="Code Climate Maintainability" /></a>
<a href="https://kaos.sh/b/rep"><img src="https://kaos.sh/b/07867ea4-6025-47a8-ad18-112dd7b37a3c.svg" alt="codebeat badge" /></a>
<a href="https://kaos.sh/w/rep/ci"><img src="https://kaos.sh/w/rep/ci.svg" alt="GitHub Actions CI Status" /></a>
<a href="https://kaos.sh/w/rep/codeql"><img src="https://kaos.sh/w/rep/codeql.svg" alt="GitHub Actions CodeQL Status" /></a>
Expand Down Expand Up @@ -69,7 +69,7 @@
which-source query… Show source package name
info package Show info about package
payload package type Show package payload
cleanup num Remove old versions of packages
cleanup num filter Remove old versions of packages
check errors-num Check repositories consistency
sign file… Sign one or more packages
resign Resign all packages in repository
Expand All @@ -84,22 +84,23 @@

Options

--release, -r Run command only on release (stable) repository
--testing, -t Run command only on testing (unstable) repository
--all, -a Run command on all repositories
--arch, -aa arch Package architecture (helpful with "info" and "payload" commands)
--move, -m Move (remove after successful action) packages (helpful with "add" command)
--no-source, -ns Ignore source packages (helpful with "add" command)
--ignore-filter, -if Ignore repository file filter (helpful with "add" and "sign" commands)
--force, -f Answer "yes" for all questions
--full, -F Full reindex (helpful with "reindex" command)
--show-all, -A Show all versions of packages (helpful with "list" command)
--status, -S Show package status (released or not)
--epoch, -E Show epoch info (helpful with "list" and "which-source" commands)
--pager, -P Run command in "pager" mode (i.e. don't disable colors and don't show raw output)
--no-color, -nc Disable colors in output
--help, -h Show this help message
--version, -v Show version
--release, -r Run command only on release (stable) repository
--testing, -t Run command only on testing (unstable) repository
--all, -a Run command on all repositories
--arch, -aa arch Package architecture (helpful with "info" and "payload" commands)
--move, -m Move (remove after successful action) packages (helpful with "add" command)
--no-source, -ns Ignore source packages (helpful with "add" command)
--ignore-filter, -if Ignore repository file filter (helpful with "add" and "sign" commands)
--postpone-index, -pi Postpone repository reindex (helpful with "add", "remove", "release", and "unrelase" commands)
--force, -f Answer "yes" for all questions
--full, -F Full reindex (helpful with "reindex" command)
--show-all, -A Show all versions of packages (helpful with "list" command)
--status, -S Show package status (released or not)
--epoch, -E Show epoch info (helpful with "list" and "which-source" commands)
--pager, -P Use pager for long output
--no-color, -nc Disable colors in output
--help, -h Show this help message
--version, -v Show versio

Check warning on line 103 in README.md

View workflow job for this annotation

GitHub Actions / Typos

"versio" should be "version".

Check warning on line 103 in README.md

View workflow job for this annotation

GitHub Actions / Typos

"versio" should be "version".
```

### CI Status
Expand Down
168 changes: 80 additions & 88 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ package cli
import (
"fmt"
"os"
"strings"

"github.com/essentialkaos/ek/v12/env"
"github.com/essentialkaos/ek/v12/fmtc"
"github.com/essentialkaos/ek/v12/fmtutil"
"github.com/essentialkaos/ek/v12/fsutil"
"github.com/essentialkaos/ek/v12/knf"
"github.com/essentialkaos/ek/v12/options"
"github.com/essentialkaos/ek/v12/pager"
"github.com/essentialkaos/ek/v12/progress"
"github.com/essentialkaos/ek/v12/signal"
"github.com/essentialkaos/ek/v12/system"
"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"
Expand All @@ -44,7 +44,7 @@ import (
// App info
const (
APP = "rep"
VER = "3.2.0"
VER = "3.3.0"
DESC = "DNF/YUM repository management utility"
)

Expand Down Expand Up @@ -144,22 +144,23 @@ const (

// Options
const (
OPT_TESTING = "t:testing"
OPT_RELEASE = "r:release"
OPT_ALL = "a:all"
OPT_ARCH = "aa:arch"
OPT_MOVE = "m:move"
OPT_NO_SOURCE = "ns:no-source"
OPT_IGNORE_FILTER = "if:ignore-filter"
OPT_FORCE = "f:force"
OPT_FULL = "F:full"
OPT_SHOW_ALL = "A:show-all"
OPT_EPOCH = "E:epoch"
OPT_STATUS = "S:status"
OPT_PAGER = "P:pager"
OPT_NO_COLOR = "nc:no-color"
OPT_HELP = "h:help"
OPT_VER = "v:version"
OPT_TESTING = "t:testing"
OPT_RELEASE = "r:release"
OPT_ALL = "a:all"
OPT_ARCH = "aa:arch"
OPT_MOVE = "m:move"
OPT_NO_SOURCE = "ns:no-source"
OPT_IGNORE_FILTER = "if:ignore-filter"
OPT_POSTPONE_INDEX = "pi:postpone-index"
OPT_FORCE = "f:force"
OPT_FULL = "F:full"
OPT_SHOW_ALL = "A:show-all"
OPT_EPOCH = "E:epoch"
OPT_STATUS = "S:status"
OPT_PAGER = "P:pager"
OPT_NO_COLOR = "nc:no-color"
OPT_HELP = "h:help"
OPT_VER = "v:version"

OPT_DEBUG = "D:debug"
OPT_VERB_VER = "vv:verbose-version"
Expand All @@ -180,22 +181,23 @@ const CONFIG_DIR = "/etc/rep.d"

// optMap is map with supported options
var optMap = options.Map{
OPT_ARCH: {},
OPT_TESTING: {Type: options.BOOL},
OPT_RELEASE: {Type: options.BOOL},
OPT_ALL: {Type: options.BOOL},
OPT_MOVE: {Type: options.BOOL},
OPT_NO_SOURCE: {Type: options.BOOL},
OPT_IGNORE_FILTER: {Type: options.BOOL},
OPT_FORCE: {Type: options.BOOL},
OPT_FULL: {Type: options.BOOL},
OPT_SHOW_ALL: {Type: options.BOOL},
OPT_EPOCH: {Type: options.BOOL},
OPT_STATUS: {Type: options.BOOL},
OPT_PAGER: {Type: options.BOOL},
OPT_NO_COLOR: {Type: options.BOOL},
OPT_HELP: {Type: options.BOOL},
OPT_VER: {Type: options.MIXED},
OPT_ARCH: {},
OPT_TESTING: {Type: options.BOOL},
OPT_RELEASE: {Type: options.BOOL},
OPT_ALL: {Type: options.BOOL},
OPT_MOVE: {Type: options.BOOL},
OPT_NO_SOURCE: {Type: options.BOOL},
OPT_IGNORE_FILTER: {Type: options.BOOL},
OPT_POSTPONE_INDEX: {Type: options.BOOL},
OPT_FORCE: {Type: options.BOOL},
OPT_FULL: {Type: options.BOOL},
OPT_SHOW_ALL: {Type: options.BOOL},
OPT_EPOCH: {Type: options.BOOL},
OPT_STATUS: {Type: options.BOOL},
OPT_PAGER: {Type: options.BOOL},
OPT_NO_COLOR: {Type: options.BOOL},
OPT_HELP: {Type: options.BOOL},
OPT_VER: {Type: options.MIXED},

OPT_DEBUG: {Type: options.BOOL},
OPT_VERB_VER: {Type: options.BOOL},
Expand Down Expand Up @@ -274,9 +276,6 @@ func Init(gitRev string, gomod []byte) {

// configureUI configure user interface
func configureUI() {
envVars := env.Get()
term := envVars.GetS("TERM")

fmtc.DisableColors = true
fmtutil.SizeSeparator = " "
fmtutil.SeparatorSymbol = "–"
Expand All @@ -300,30 +299,23 @@ func configureUI() {
fmtc.NameColor("package", "{m}")
fmtc.NameColor("repo", "{c}")

if fmtc.IsColorsSupported() {
fmtc.DisableColors = false
}

if fmtc.Is256ColorsSupported() {
fmtc.NameColor("package", "{#108}")
fmtc.NameColor("repo", "{#33}")
progress.DefaultSettings.BarFgColorTag = "{#33}"
}

if term != "" {
switch {
case strings.Contains(term, "xterm"),
strings.Contains(term, "color"),
term == "screen":
fmtc.DisableColors = false
}
}

if options.GetB(OPT_NO_COLOR) {
fmtc.DisableColors = true
}

if !options.GetB(OPT_PAGER) {
if !fsutil.IsCharacterDevice("/dev/stdout") && envVars.GetS("FAKETTY") == "" {
fmtc.DisableColors = true
rawOutput = true
}
if !tty.IsTTY() {
fmtc.DisableColors = true
rawOutput = true
}
}

Expand All @@ -333,12 +325,12 @@ func checkPermissions() {

if err != nil {
terminal.Error("Can't get info about current user: %v", err)
os.Exit(1)
shutdown(1)
}

if !curUser.IsRoot() {
terminal.Error("This app requires superuser (root) privileges")
os.Exit(1)
shutdown(1)
}
}

Expand All @@ -348,7 +340,7 @@ func loadGlobalConfig() {

if err != nil {
terminal.Error(err.Error())
os.Exit(1)
shutdown(1)
}
}

Expand Down Expand Up @@ -383,7 +375,7 @@ func validateGlobalConfig() {
terminal.Error(" - %v", err)
}

os.Exit(1)
shutdown(1)
}

// loadRepoConfigs loads repositories configuration files
Expand All @@ -404,7 +396,7 @@ func loadRepoConfigs() {

if err != nil {
terminal.Error(err.Error())
os.Exit(1)
shutdown(1)
}

configs[cfg.GetS(REPOSITORY_NAME)] = cfg
Expand Down Expand Up @@ -448,7 +440,7 @@ func validateRepoConfigs() {
}

if hasErrors {
os.Exit(1)
shutdown(1)
}
}

Expand All @@ -472,7 +464,7 @@ func configureRepoCache() {
}

if hasErrors {
os.Exit(1)
shutdown(1)
}
}

Expand Down Expand Up @@ -521,6 +513,12 @@ func process(args options.Arguments) bool {
return false
}

if options.GetB(OPT_PAGER) && tty.IsTTY() {
if pager.Setup() == nil {
defer pager.Complete()
}
}

// List repositories by default
if args.Get(1).String() == "" {
return runCommand(configs[repo], COMMAND_LIST, nil)
Expand Down Expand Up @@ -551,11 +549,11 @@ func printCompletion() int {

switch options.GetS(OPT_COMPLETION) {
case "bash":
fmt.Printf(bash.Generate(info, APP))
fmt.Print(bash.Generate(info, APP))
case "fish":
fmt.Printf(fish.Generate(info, APP))
fmt.Print(fish.Generate(info, APP))
case "zsh":
fmt.Printf(zsh.Generate(info, optMap, APP))
fmt.Print(zsh.Generate(info, optMap, APP))
default:
return 1
}
Expand All @@ -573,27 +571,18 @@ func printMan() {
)
}

// 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()

if fmtc.Is256ColorsSupported() {
info.AppNameColorTag = "{*}{#33}"
}

info.AddSpoiler(
"Notice that if you have more than one repository you should define its name as\n" +
"the first argument. You can read detailed info about every command with usage\n" +
"examples using {y}help{!} command.",
)
` Note that if you have more than one repository, you should specify its name
as the first argument. You can read detailed information about each command
with usage examples by using the {y}help{!} command.`)

info.AddCommand(COMMAND_INIT, "Initialize new repository", "arch…")
info.AddCommand(COMMAND_GEN_KEY, "Generate keys for signing packages")
Expand All @@ -602,7 +591,7 @@ func genUsage() *usage.Info {
info.AddCommand(COMMAND_WHICH_SOURCE, "Show source package name", "query…")
info.AddCommand(COMMAND_INFO, "Show info about package", "package")
info.AddCommand(COMMAND_PAYLOAD, "Show package payload", "package", "?type")
info.AddCommand(COMMAND_CLEANUP, "Remove old versions of packages", "?num")
info.AddCommand(COMMAND_CLEANUP, "Remove old versions of packages", "?num", "?filter")
info.AddCommand(COMMAND_CHECK, "Check repositories consistency", "?errors-num")
info.AddCommand(COMMAND_SIGN, "Sign one or more packages", "file…")
info.AddCommand(COMMAND_RESIGN, "Resign all packages in repository")
Expand All @@ -618,16 +607,17 @@ func genUsage() *usage.Info {
info.AddOption(OPT_RELEASE, "Run command only on release {s}(stable){!} repository")
info.AddOption(OPT_TESTING, "Run command only on testing {s}(unstable){!} repository")
info.AddOption(OPT_ALL, "Run command on all repositories")
info.AddOption(OPT_ARCH, "Package architecture {s-}(helpful with \"info\" and \"payload\" commands){!}", "arch")
info.AddOption(OPT_MOVE, "Move {s}(remove after successful action){!} packages {s-}(helpful with \"add\" command){!}")
info.AddOption(OPT_NO_SOURCE, "Ignore source packages {s-}(helpful with \"add\" command){!}")
info.AddOption(OPT_IGNORE_FILTER, "Ignore repository file filter {s-}(helpful with \"add\" and \"sign\" commands){!}")
info.AddOption(OPT_FORCE, "Answer \"yes\" for all questions")
info.AddOption(OPT_FULL, "Full reindex {s-}(helpful with \"reindex\" command){!}")
info.AddOption(OPT_SHOW_ALL, "Show all versions of packages {s-}(helpful with \"list\" command){!}")
info.AddOption(OPT_ARCH, `Package architecture {s-}(helpful with "info" and "payload" commands){!}`, "arch")
info.AddOption(OPT_MOVE, `Move {s}(remove after successful action){!} packages {s-}(helpful with "add" command){!}`)
info.AddOption(OPT_NO_SOURCE, `Ignore source packages {s-}(helpful with "add" command){!}`)
info.AddOption(OPT_IGNORE_FILTER, `Ignore repository file filter {s-}(helpful with "add" and "sign" commands){!}`)
info.AddOption(OPT_POSTPONE_INDEX, `Postpone repository reindex {s-}(helpful with "add", "remove", "release", and "unrelase" commands){!}`)
info.AddOption(OPT_FORCE, `Answer "yes" for all questions`)
info.AddOption(OPT_FULL, `Full reindex {s-}(helpful with "reindex" command){!}`)
info.AddOption(OPT_SHOW_ALL, `Show all versions of packages {s-}(helpful with "list" command){!}`)
info.AddOption(OPT_STATUS, "Show package status {s-}(released or not){!}")
info.AddOption(OPT_EPOCH, "Show epoch info {s-}(helpful with \"list\" and \"which-source\" commands){!}")
info.AddOption(OPT_PAGER, "Run command in \"pager\" mode {s-}(i.e. don't disable colors and don't show raw output){!}")
info.AddOption(OPT_EPOCH, `Show epoch info {s-}(helpful with "list" and "which-source" commands){!}`)
info.AddOption(OPT_PAGER, "Use pager for long output")
info.AddOption(OPT_NO_COLOR, "Disable colors in output")
info.AddOption(OPT_HELP, "Show this help message")
info.AddOption(OPT_VER, "Show version")
Expand Down Expand Up @@ -685,6 +675,8 @@ func genAbout(gitRev string) *usage.About {
Owner: "ESSENTIAL KAOS",
License: "Apache License, Version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>",
UpdateChecker: usage.UpdateChecker{"essentialkaos/rep", update.GitHubChecker},

DescSeparator: "{s}—{!}",
}

if gitRev != "" {
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func addRPMFiles(ctx *context, files []string, signingKey *sign.Key) bool {
hasAdded = true
}

if hasAdded {
if hasAdded && !options.GetB(OPT_POSTPONE_INDEX) {
fmtc.NewLine()
reindexRepository(ctx, ctx.Repo.Testing, false)
}
Expand Down
Loading
Loading