mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
Revert "add path extension func to stdlib-candidate"
This reverts commit b50215132b
.
This commit is contained in:
parent
b50215132b
commit
43d122448c
2 changed files with 1 additions and 29 deletions
|
@ -3,6 +3,6 @@
|
||||||
description: "Official candidates for Nushell standard library"
|
description: "Official candidates for Nushell standard library"
|
||||||
documentation: "https://github.com/nushell/nu_scripts/blob/main/stdlib-candidate/std-rfc/README.md"
|
documentation: "https://github.com/nushell/nu_scripts/blob/main/stdlib-candidate/std-rfc/README.md"
|
||||||
license: "https://github.com/nushell/nu_scripts/blob/main/LICENSE"
|
license: "https://github.com/nushell/nu_scripts/blob/main/LICENSE"
|
||||||
version: 0.4.1
|
version: 0.4.0
|
||||||
type: "module"
|
type: "module"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
# Update extension of input files.
|
|
||||||
#
|
|
||||||
# # Example
|
|
||||||
# - setting path ext to `rs`
|
|
||||||
# ```nushell
|
|
||||||
# > "ab.txt" | path extension "rs"
|
|
||||||
# ab.rs
|
|
||||||
# > "ab.txt" | path extension ".rs"
|
|
||||||
# ab.rs
|
|
||||||
#
|
|
||||||
# - setting a list of input path ext to `rs`
|
|
||||||
# > ["ab.txt", "cd.exe"] | path extension "rs"
|
|
||||||
# ╭───┬──────────╮
|
|
||||||
# │ 0 │ ab.rs │
|
|
||||||
# │ 1 │ cd.rs │
|
|
||||||
# ╰───┴──────────╯
|
|
||||||
# ```
|
|
||||||
export def extension [
|
|
||||||
ext: string
|
|
||||||
] {
|
|
||||||
let path_parsed = $in | path parse
|
|
||||||
if ($ext | str starts-with ".") {
|
|
||||||
$path_parsed | update extension ($ext | str substring 1..) | path join
|
|
||||||
} else {
|
|
||||||
$path_parsed | update extension $ext | path join
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue