Skip to content

Commit

Permalink
Merge pull request #41 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 0.0.6
  • Loading branch information
andyone authored Dec 18, 2023
2 parents c4fed7d + 155b226 commit 118de7e
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 302 deletions.
37 changes: 16 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ jobs:

strategy:
matrix:
go: [ '1.20.x' ]
go: [ '1.20.x', '1.21.x' ]

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

Expand All @@ -46,14 +46,6 @@ jobs:
- name: Run tests
run: make all

- name: Upload built artifacts
uses: actions/upload-artifact@v3
with:
name: path
path: ${{github.workspace}}/path
if-no-files-found: error
retention-days: 1

Bibop:
name: Bibop
runs-on: ubuntu-latest
Expand All @@ -62,16 +54,18 @@ jobs:

steps:
- name: Code checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download pre-built artifacts
uses: actions/download-artifact@v3
- name: Set up Go
uses: actions/setup-go@v5
with:
name: path
path: ${{github.workspace}}
go-version: '1.21.x'

- name: Download dependencies
run: make deps

- name: Restore permissions
run: chmod +x path
- name: Run tests
run: make all

- name: Run bibop tests
uses: essentialkaos/bibop-action@v1
Expand All @@ -87,10 +81,10 @@ jobs:

steps:
- name: Code checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -109,7 +103,8 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check spelling
continue-on-error: true
uses: crate-ci/typos@master
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################

# This Makefile generated by GoMakeGen 2.2.0 using next command:
# This Makefile generated by GoMakeGen 2.3.0 using next command:
# gomakegen --mod .
#
# More info: https://kaos.sh/gomakegen
Expand All @@ -13,6 +13,7 @@ ifdef VERBOSE ## Print verbose information (Flag)
VERBOSE_FLAG = -v
endif

COMPAT ?= 1.18
MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD)

Expand Down Expand Up @@ -50,7 +51,7 @@ else
endif

ifdef COMPAT ## Compatible Go version (String)
go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT)
go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT)
else
go mod tidy $(VERBOSE_FLAG)
endif
Expand Down Expand Up @@ -94,6 +95,6 @@ help: ## Show this info
| sed 's/ifdef //' \
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 2.2.0\033[0m\n'
@echo -e '\033[90mGenerated by GoMakeGen 2.3.0\033[0m\n'

################################################################################
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ To build the `path` from scratch, make sure you have a working Go 1.20+ workspac
go install github.com/essentialkaos/path@latest
```

#### From [ESSENTIAL KAOS Public Repository](https://yum.kaos.st) for EL 7/8/9
#### From [ESSENTIAL KAOS Public Repository](https://kaos.sh/kaos-repo) for EL 7/8/9

```bash
sudo yum install -y https://yum.kaos.st/kaos-repo-latest.el$(grep 'CPE_NAME' /etc/os-release | tr -d '"' | cut -d':' -f5).noarch.rpm
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
sudo yum install path
```

Expand Down
69 changes: 26 additions & 43 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"strings"

"github.com/essentialkaos/ek/v12/fmtc"
"github.com/essentialkaos/ek/v12/fsutil"
"github.com/essentialkaos/ek/v12/options"
"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 @@ -30,7 +30,7 @@ import (
// Basic utility info
const (
APP = "path"
VER = "0.0.5"
VER = "0.0.6"
DESC = "Dead simple tool for working with paths"
)

Expand Down Expand Up @@ -143,24 +143,7 @@ func Run(gitRev string, gomod []byte) {

// preConfigureUI preconfigures UI based on information about user terminal
func preConfigureUI() {
term := os.Getenv("TERM")

fmtc.DisableColors = true

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

if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" {
fmtc.DisableColors = true
}

if os.Getenv("NO_COLOR") != "" {
if !tty.IsTTY() {
fmtc.DisableColors = true
}
}
Expand Down Expand Up @@ -244,11 +227,11 @@ func printCompletion() int {

switch options.GetS(OPT_COMPLETION) {
case "bash":
fmt.Printf(bash.Generate(info, "path"))
fmt.Print(bash.Generate(info, "path"))
case "fish":
fmt.Printf(fish.Generate(info, "path"))
fmt.Print(fish.Generate(info, "path"))
case "zsh":
fmt.Printf(zsh.Generate(info, optMap, "path"))
fmt.Print(zsh.Generate(info, optMap, "path"))
default:
return 1
}
Expand All @@ -270,26 +253,26 @@ func printMan() {
func genUsage() *usage.Info {
info := usage.NewInfo()

info.AddCommand(CMD_BASENAME, "Strip directory and suffix from filenames")
info.AddCommand(CMD_DIRNAME, "Strip last component from file name")
info.AddCommand(CMD_READLINK, "Print resolved symbolic links or canonical file names")
info.AddCommand(CMD_CLEAN, "Print shortest path name equivalent to path by purely lexical processing")
info.AddCommand(CMD_COMPACT, "Converts path to compact representation")
info.AddCommand(CMD_ABS, "Print absolute representation of path")
info.AddCommand(CMD_EXT, "Print file extension")
info.AddCommand(CMD_MATCH, "Filter given path using pattern", "pattern")
info.AddCommand(CMD_JOIN, "Join path elements", "root")

info.AddCommand(CMD_ADD_PREFIX, "Add the substring at the beginning", "prefix")
info.AddCommand(CMD_DEL_PREFIX, "Remove the substring at the beginning", "prefix")
info.AddCommand(CMD_ADD_SUFFIX, "Add the substring at the end", "suffix")
info.AddCommand(CMD_DEL_SUFFIX, "Remove the substring at the end", "suffix")
info.AddCommand(CMD_EXCLUDE, "Exclude part of the string", "substr")

info.AddCommand(CMD_IS_ABS, "Check if given path is absolute")
info.AddCommand(CMD_IS_LOCAL, "Check if given path is local")
info.AddCommand(CMD_IS_SAFE, "Check if given path is safe")
info.AddCommand(CMD_IS_MATCH, "Check if given path is match to pattern", "pattern")
info.AddCommand(CMD_BASENAME, "Strip directory and suffix from filenames", "?path")
info.AddCommand(CMD_DIRNAME, "Strip last component from file name", "?path")
info.AddCommand(CMD_READLINK, "Print resolved symbolic links or canonical file names", "?path")
info.AddCommand(CMD_CLEAN, "Print shortest path name equivalent to path by purely lexical processing", "?path")
info.AddCommand(CMD_COMPACT, "Converts path to compact representation", "?path")
info.AddCommand(CMD_ABS, "Print absolute representation of path", "?path")
info.AddCommand(CMD_EXT, "Print file extension", "?path")
info.AddCommand(CMD_MATCH, "Filter given path using pattern", "pattern", "?path")
info.AddCommand(CMD_JOIN, "Join path elements", "root", "?path")

info.AddCommand(CMD_ADD_PREFIX, "Add the substring at the beginning", "prefix", "?path")
info.AddCommand(CMD_DEL_PREFIX, "Remove the substring at the beginning", "prefix", "?path")
info.AddCommand(CMD_ADD_SUFFIX, "Add the substring at the end", "suffix", "?path")
info.AddCommand(CMD_DEL_SUFFIX, "Remove the substring at the end", "suffix", "?path")
info.AddCommand(CMD_EXCLUDE, "Exclude part of the string", "substr", "?path")

info.AddCommand(CMD_IS_ABS, "Check if given path is absolute", "?path")
info.AddCommand(CMD_IS_LOCAL, "Check if given path is local", "?path")
info.AddCommand(CMD_IS_SAFE, "Check if given path is safe", "?path")
info.AddCommand(CMD_IS_MATCH, "Check if given path is match to pattern", "pattern", "?path")

info.AddOption(OPT_ZERO, "End each output line with NUL, not newline")
info.AddOption(OPT_SPACE, "End each output line with space, not newline")
Expand Down
Loading

0 comments on commit 118de7e

Please sign in to comment.