Small, focused CLI that merges the behavior of dirname and basename with a few convenient extras. Designed for shell scripts and Makefiles where a compact, predictable filename-manipulation utility is useful.
- From source (recommended):
go install github.com/grimdork/name@latest- Build locally:
make buildname [OPTIONS]... [FILENAME]
name -hshows helpname -vprints the build version and build date (when provided via ldflags)
-p,--nopath— return only the base filename (strip directory path)-s,--stripsuffix— strip the suffix (file extension) from the name-S,--onlysuffix— return only the suffix (extension) without the leading dot-n,--noname— return only the path (directory component)-a,--absolute— expand the name to an absolute path
# basename-like
name -p /usr/bin/env
# => env
# strip suffix
name -s main.go
# => main
# suffix only
name -S archive.tar.gz
# => gz
# dirname-like
name -n /sbin/ping6
# => /sbin
# absolute path
name -a main.go
# => /home/alice/src/name/main.go
# combined: absolute + strip suffix
name -as main.go
# => /home/alice/src/name/main- The
-S(only suffix) flag takes precedence and returns immediately; other flags are not applied when-Sis used. - When
-n(directory-only) is used on a bare filename (e.g.foo),filepath.Dir("foo")returns.; this tool normalises that to an empty string for scripting convenience. - Suffix handling follows
filepath.Ext: the suffix is the final.component. Forarchive.tar.gzthe suffix isgzand-sremoves only the final.gz.
- Run tests:
make test- Vulnerability scan:
make govulncheck- Linting is currently disabled in CI due to a runner/tooling compatibility issue; the Makefile includes a placeholder
linttarget.
Open issues and PRs are welcome. Please run the test suite and include a short description of your change.
MIT — see LICENSE