Skip to content

Commit

Permalink
feat(std): more command
Browse files Browse the repository at this point in the history
  • Loading branch information
Mte90 committed Jun 12, 2024
1 parent 69e96ae commit 69a1d04
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/std/main.ab
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,56 @@ pub fun includes(arr, value) {
}
return false
}

pub fun move(origin: Text, destination: Text): Null {
unsafe $mv "{origin}" "{destination}"$
}

pub fun change_dir(path: Text): Null {
if dir_exist(origin) {
unsafe $cd "{path}" || exit$
}

return false
}

pub fun make_symbolic_link(origin: Text, destination: Text): Null {
if file_exist(origin) {
unsafe $ln -s "{origin}" "{path}"$
return true
}

echo "The file {$origin} doesn't exist!"
return false
}

pub fun create_dir(path: Text): Null {
if not dir_exist(origin) {
unsafe $mkdir -p "{path}"$
}
}

pub fun make_executable(path: Text): Null {
if file_exist(origin) {
unsafe $chmod +x "{path}"$
return true
}

echo "The file {$path} doesn't exist!"
return false
}

pub fun switch_user_permission(user: Text, path: Text): Null {
// TODO when OR will be available we need to check if the folder or file exist
unsafe $chown -R "{user}" "{path}"$
}

pub fun delete(path: Text): Null {
if not includes(['/', '.', '..'], path) {
unsafe $rm -fr "{path}"$
return true
}

echo "The file {$path} can't be deleted!"
return false
}

0 comments on commit 69a1d04

Please sign in to comment.