4 releases (breaking)
0.4.0 | Dec 23, 2024 |
---|---|
0.3.0 | Dec 5, 2022 |
0.2.0 | Dec 4, 2022 |
0.1.0 | Dec 2, 2022 |
#235 in Text processing
125 downloads per month
30KB
712 lines
pathmut
is a path string manipulation utility
This was made because I'm tired of resorting to basename
, dirname
, cut -d. -f1
or whatever other random core util to just extract some information from path names.
Important to know this utility only works with path strings and doesn't touch the file system whatsoever.
$ pathmut
Mutates path strings.
Usage: pathmut [COMMAND or COMPONENT]
Commands:
get Read a file component [default]
delete Remove a file component
replace Replace a file component
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help information
-V, --version Print version information
Components:
ext file extension
stem file stem
prefix file prefix
name file name
parent parent of the file or directory
n ordinal of the nth component
Installation
For now, you have to build from source. The package is available on crates.io.
cargo install pathmut
Documentation
This utility is really just a command line wrapper for Rust's Path struct API. Precise details on exactly how these commands work are found there.
Future Development
I'd like this to be the all in one tool for manipulating path strings. This tool should never touch or look at the actual filesystem, which means it shouldn't be able to answer if a path exists, if something is a file, create files, etc.
I should be able to ask questions about path strings, like the following:
- Is the path absolute or relative?
- Is this a windows path or a unix path?
- Is the path valid, if it did exist?
- What is the depth of the path?
I should be able to manipulate paths as a whole:
- I should canonicalize a path (remove redundant
../
and./
)
I should be able to work with multiple paths:
- Does path A begin with path B?
- Does path A end with path B?
- Is path B contained with path A?
- Join path A and path B together.
Changelog
v0.4.0
- Remove
--remove
and--replace
args withdelete
andreplace
commands - Add
get
command (default behavior) - Components are now arguments to
get
,delete
, andreplace
- Specify nth component by using number,
0
for first component, etc. - Remove
first
component
v0.3.0
- Add
first
command - Add
--remove
and--replace
arguments for every command - Remove
rmext
command
v0.2.0
- Show help by default
- Read from stdin, all at once
- Allow passing multiple file paths as args (not stdin)
- Add
rmext
command
v0.1.0
- Add
ext
,stem
,prefix
,name
,parent
commands.
Dependencies
~2–10MB
~124K SLoC