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

Merged
merged 20 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b8d42e6
Regenerate Makefile with the latest version of gomakegen
andyone Oct 10, 2024
fd3602b
Dependencies update
andyone Oct 10, 2024
2c76268
Improve README
andyone Oct 10, 2024
853bd7f
Bump github.com/essentialkaos/ek/v13 in the all group across 1 directory
dependabot[bot] Oct 15, 2024
16c9dd0
Merge pull request #81 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 17, 2024
0814516
Bump github.com/essentialkaos/ek/v13 in the all group
dependabot[bot] Oct 18, 2024
2201613
Merge pull request #82 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 18, 2024
e6442e1
Bump github.com/essentialkaos/ek/v13 in the all group
dependabot[bot] Oct 21, 2024
193c719
Merge pull request #83 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 21, 2024
e017c3d
Fix compatibility with the latest version of ek package
andyone Oct 21, 2024
d03e98c
Bump github.com/essentialkaos/ek/v13 in the all group across 1 directory
dependabot[bot] Oct 29, 2024
c75d6e9
Merge pull request #85 from essentialkaos/dependabot/go_modules/devel…
andyone Oct 30, 2024
272d347
Bump github.com/essentialkaos/ek/v13 in the all group
dependabot[bot] Nov 1, 2024
40baea0
Merge pull request #86 from essentialkaos/dependabot/go_modules/devel…
andyone Nov 1, 2024
4f08e0c
Dependencies update
andyone Nov 8, 2024
148bb2f
Add 'strip-ext' command
andyone Nov 8, 2024
3459dd3
Regenerate usage svg
andyone Nov 8, 2024
d0009c0
Update bibop tests
andyone Nov 8, 2024
469f1cd
Improve README
andyone Nov 8, 2024
9787b6b
Improve help content
andyone Nov 8, 2024
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
6 changes: 6 additions & 0 deletions .bibop/path.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ command "path -s exclude _small john_small.jpg bob_small.jpg jack_small.jpg"

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

command "path -s strip-ext john.jpg bob.png jack.TIFF"
exit 0
output-contains "john bob jack"

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

command "path is-abs /home/user/bob/file.txt" "Check is-abs command"
exit 0

Expand Down
85 changes: 43 additions & 42 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.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################

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

COMPAT ?= 1.19
ifdef PROXY ## Force proxy usage for downloading dependencies (Flag)
export GOPROXY=https://proxy.golang.org/cached-only,direct
endif

ifdef CGO ## Enable CGO usage (Flag)
export CGO_ENABLED=1
else
export CGO_ENABLED=0
endif

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

Expand Down Expand Up @@ -107,8 +116,9 @@ help: ## Show this info
@echo -e '\n\033[1mVariables:\033[0m\n'
@grep -E '^ifdef [A-Z_]+ .*?## .*$$' $(abspath $(lastword $(MAKEFILE_LIST))) \
| sed 's/ifdef //' \
| sort -h \
| awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-11s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 3.0.2\033[0m\n'
@echo -e '\033[90mGenerated by GoMakeGen 3.2.1\033[0m\n'

################################################################################
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ find . -mindepth 1 -maxdepth 1 -type d -exec basename {} \;
find . -mindepth 1 -maxdepth 1 -type d | path basename
```

Also, it works MUCH faster:
Also, it works **MUCH** faster (~120x):

```
$ git clone https://github.com/kubernetes/kubernetes.git --depth=1
Expand All @@ -60,17 +60,17 @@ Summary

#### From source

To build the `path` from scratch, make sure you have a working Go 1.22+ workspace (_[instructions](https://go.dev/doc/install)_), then:
To build the `path` from scratch, make sure you have a working [Go 1.22+](https://github.com/essentialkaos/.github/blob/master/GO-VERSION-SUPPORT.md) workspace (_[instructions](https://go.dev/doc/install)_), then:

```
go install github.com/essentialkaos/path@latest
```

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

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

#### Prebuilt binaries
Expand Down
50 changes: 27 additions & 23 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
// Basic utility info
const (
APP = "path"
VER = "1.0.3"
VER = "1.1.0"
DESC = "Dead simple tool for working with paths"
)

Expand Down Expand Up @@ -70,6 +70,7 @@ const (
CMD_ADD_SUFFIX = "add-suffix"
CMD_DEL_SUFFIX = "del-suffix"
CMD_EXCLUDE = "exclude"
CMD_STRIP_EXT = "strip-ext"

CMD_IS_ABS = "is-abs"
CMD_IS_LOCAL = "is-local"
Expand Down Expand Up @@ -108,7 +109,7 @@ func Run(gitRev string, gomod []byte) {

if !errs.IsEmpty() {
terminal.Error("Options parsing errors:")
terminal.Error(errs.String())
terminal.Error(errs.Error("- "))
os.Exit(1)
}

Expand Down Expand Up @@ -200,6 +201,8 @@ func process(args options.Arguments) (error, bool) {
return cmdDelSuffix(cmdArgs)
case CMD_EXCLUDE:
return cmdExclude(cmdArgs)
case CMD_STRIP_EXT:
return cmdStripExt(cmdArgs)

case CMD_IS_ABS:
return cmdIsAbs(cmdArgs)
Expand Down Expand Up @@ -252,27 +255,28 @@ func printMan() {
func genUsage() *usage.Info {
info := usage.NewInfo()

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_DIRNAME_NUM, "Return N elements from path", "num", "?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.AddCommand(CMD_BASENAME, "Strip directory and suffix from filenames", "?path…")
info.AddCommand(CMD_DIRNAME, "Strip last component from file name", "?path…")
info.AddCommand(CMD_DIRNAME_NUM, "Return N elements from path", "num", "?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_STRIP_EXT, "Remove file extension", "?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