-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up str append/prepend a little (#797)
- Move to directory for other `str` contributions - Add simple `help` docs - Simplify type check since only 2 cases are possible @savente93 Are these okay?
- Loading branch information
1 parent
7d662ad
commit 707cda3
Showing
7 changed files
with
61 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# modules | ||
export module record/ | ||
export module str.nu | ||
export module str/ | ||
# commands | ||
export use fs.nu * | ||
export use set-env.nu * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export use xpend.nu * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Append a suffix to an input string or list of strings. | ||
# | ||
# Examples: | ||
# Output 'hello world' | ||
# > 'hello' | str append ' world' | ||
# | ||
# Output file names suffixed with '_world' | ||
# > ls | get name | str append _world | ||
export def append [ | ||
suffix: string | ||
]: [string -> string, list<string> -> list<string>] { | ||
let input = $in | ||
let append = { $in + $suffix } | ||
if ($input | describe) == string { | ||
$input | do $append | ||
} else { | ||
$input | each $append | ||
} | ||
} | ||
|
||
# Prepend a prefix to an input string or list of strings. | ||
# | ||
# Examples: | ||
# Output 'hello world' | ||
# > 'world' | str prepend 'hello ' | ||
# | ||
# Output file names prefixed with 'hello_' | ||
# > ls | get name | str prepend hello_ | ||
export def prepend [ | ||
prefix: string | ||
]: [string -> string, list<string> -> list<string>] { | ||
let input = $in | ||
let prepend = { $prefix + $in } | ||
if ($input | describe) == string { | ||
$input | do $prepend | ||
} else { | ||
$input | each $prepend | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export module fs.nu | ||
export module record.nu | ||
export module str.nu | ||
export module str_xpend.nu |
File renamed without changes.