File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 33 description: "Official candidates for Nushell standard library"
44 documentation: "https://github.com/nushell/nu_scripts/blob/main/stdlib-candidate/std-rfc/README.md"
55 license: "https://github.com/nushell/nu_scripts/blob/main/LICENSE"
6- version: 0.4.0
6+ version: 0.4.1
77 type: "module"
88}
Original file line number Diff line number Diff line change 1+ # Update extension of input files.
2+ #
3+ # # Example
4+ # - setting path ext to `rs`
5+ # ```nushell
6+ # > "ab.txt" | path extension "rs"
7+ # ab.rs
8+ # > "ab.txt" | path extension ".rs"
9+ # ab.rs
10+ #
11+ # - setting a list of input path ext to `rs`
12+ # > ["ab.txt", "cd.exe"] | path extension "rs"
13+ # ╭───┬──────────╮
14+ # │ 0 │ ab.rs │
15+ # │ 1 │ cd.rs │
16+ # ╰───┴──────────╯
17+ # ```
18+ export def extension [
19+ ext : string
20+ ] {
21+ let path_parsed = $in | path parse
22+ if ($ext | str starts-with " ." ) {
23+ $path_parsed | update extension ($ext | str substring 1 .. ) | path join
24+ } else {
25+ $path_parsed | update extension $ext | path join
26+ }
27+ }
28+
You can’t perform that action at this time.
0 commit comments