Skip to content

Commit

Permalink
feat(doc): stdlib first incomplete version
Browse files Browse the repository at this point in the history
  • Loading branch information
Mte90 committed Jul 23, 2024
1 parent 4c6f14b commit 5c3560a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/std/fs.ab
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * from "std/env"

/// Check if directory exists
pub fun dir_exist(path) {
$[ -d "{path}" ]$ failed {
Expand Down Expand Up @@ -36,7 +38,7 @@ pub fun create_symbolic_link(origin: Text, destination: Text): Bool {
return true
}

echo "The file {origin} doesn't exist!"
error("The file {origin} doesn't exist!")
return false
}

Expand All @@ -54,7 +56,7 @@ pub fun make_executable(path: Text): Bool {
return true
}

echo "The file {path} doesn't exist!"
error("The file {path} doesn't exist!")
return false
}

Expand Down
8 changes: 4 additions & 4 deletions src/std/text.ab
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ pub fun join(list: [Text], delimiter: Text): Text {
return unsafe $IFS="{delimiter}" ; echo "\$\{{nameof list}[*]}"$
}

/// Trim the spaces at top of the string
/// Trim the spaces at top of the string using `sed`
pub fun trim_left(text: Text): Text {
return unsafe $echo "{text}" | sed -e 's/^[[:space:]]*//'$
}

/// Trim the spaces at end of the string
/// Trim the spaces at end of the string using `sed`
pub fun trim_right(text: Text): Text {
return unsafe $echo "{text}" | sed -e 's/[[:space:]]*\$//'$
}
Expand All @@ -50,12 +50,12 @@ pub fun trim(text: Text): Text {
return trim_left(trim_right(text))
}

/// Lowercase the string input
/// Lowercase the string input using `tr`
pub fun lower(text: Text): Text {
return unsafe $echo "{text}" | tr '[:upper:]' '[:lower:]'$
}

/// Lowercase the string input
/// Lowercase the string input using `tr`
pub fun upper(text: Text): Text {
return unsafe $echo "{text}" | tr '[:lower:]' '[:upper:]'$
}
Expand Down

0 comments on commit 5c3560a

Please sign in to comment.