Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename standard library functions #639

Merged
merged 9 commits into from
Dec 19, 2024

Conversation

hdwalters
Copy link
Contributor

@hdwalters hdwalters commented Dec 18, 2024

Rename standard library functions for internal consistency and transparency.
Rename test scripts to match, and prefix with array_ etc where not already done.

File      New Name              Old Name              Changed
--------- --------------------- --------------------- --------
array.ab  array_contains        includes              Yes
array.ab  array_extract_at      extract_at            Yes
array.ab  array_find            array_first_index     Yes
array.ab  array_find_all        array_search          Yes
array.ab  array_first           first                 Yes
array.ab  array_last            last                  Yes
array.ab  array_pop             pop                   Yes
array.ab  array_remove_at       remove_at             Yes
array.ab  array_shift           shift                 Yes
--------- --------------------- --------------------- --------
date.ab   date_add              date_add              -
date.ab   date_compare          date_compare          -
date.ab   date_now              now                   Yes
date.ab   date_posix            date_posix            -
--------- --------------------- --------------------- --------
env.ab    bold                  text_bold             Yes
env.ab    echo_colored          color_echo            Yes
env.ab    echo_error            error                 Yes
env.ab    echo_info             echo_info             -
env.ab    echo_success          echo_success          -
env.ab    echo_warning          echo_warning          -
env.ab    env_const_get         shell_constant_get    Yes
env.ab    env_const_set         shell_constant_set    Yes
env.ab    env_file_load         load_env_file         Yes
env.ab    env_var_get           shell_var_get         Yes
env.ab    env_var_load          get_env_var           Yes
env.ab    env_var_set           shell_var_set         Yes
env.ab    env_var_test          shell_isset           Yes
env.ab    env_var_unset         shell_unset           Yes
env.ab    escaped               printf_escape         Yes
env.ab    has_failed            has_failed            -
env.ab    input_confirm         confirm               Yes
env.ab    input_hidden          input_hidden          -
env.ab    input_prompt          input                 Yes
env.ab    is_command            is_command            -
env.ab    is_root               is_root               -
env.ab    italic                text_italic           Yes
env.ab    printf                printf                -
env.ab    styled                text_shell            Yes
env.ab    underlined            text_underlined       Yes
--------- --------------------- --------------------- --------
fs.ab     dir_create            create_dir            Yes
fs.ab     dir_exists            dir_exist             Yes
fs.ab     file_append           file_append           -
fs.ab     file_chmod            make_executable       Yes
fs.ab     file_chown            change_owner          Yes
fs.ab     file_exists           file_exist            Yes
fs.ab     file_extract          extract               Yes
fs.ab     file_glob             glob                  Yes
fs.ab     file_glob_all         glob_multiple         Yes
fs.ab     file_read             file_read             -
fs.ab     file_write            file_write            -
fs.ab     symlink_create        create_symbolic_link  Yes
--------- --------------------- --------------------- --------
http.ab   file_download         download              Yes
--------- --------------------- --------------------- --------
math.ab   math_abs              abs                   Yes
math.ab   math_ceil             ceil                  Yes
math.ab   math_floor            floor                 Yes
math.ab   math_round            round                 Yes
math.ab   math_sum              sum                   Yes
--------- --------------------- --------------------- --------
text.ab   capitalized           capitalize            Yes
text.ab   char_at               char_at               -
text.ab   ends_with             ends_with             -
text.ab   join                  join                  -
text.ab   lowercase             lower                 Yes
text.ab   lpad                  lpad                  -
text.ab   match_regex           match_regex           -
text.ab   match_regex_any       match_any_regex       Yes
text.ab   parse_number          parse                 Yes
text.ab   replace               replace               -
text.ab   replace_one           replace_once          Yes
text.ab   replace_regex         replace_regex         -
text.ab   reversed              reverse               Yes
text.ab   rpad                  rpad                  -
text.ab   slice                 slice                 -
text.ab   split                 split                 -
text.ab   split_chars           chars                 Yes
text.ab   split_lines           split_lines           -
text.ab   split_words           words                 Yes
text.ab   starts_with           starts_with           -
text.ab   text_contains         contains              Yes
text.ab   text_contains_all     contains_all          Yes
text.ab   text_contains_any     contains_any          Yes
text.ab   trim                  trim                  -
text.ab   trim_left             trim_left             -
text.ab   trim_right            trim_right            -
text.ab   uppercase             upper                 Yes
text.ab   zfill                 zfill                 -

@hdwalters hdwalters self-assigned this Dec 18, 2024
@hdwalters hdwalters force-pushed the rename-stdlib-functions branch from f892187 to 4ae673e Compare December 18, 2024 22:25
@hdwalters hdwalters force-pushed the rename-stdlib-functions branch from 45901b5 to 607c721 Compare December 18, 2024 22:36
pub fun make_executable(path: Text): Bool {
if file_exist(path) {
trust $ chmod +x "{path}" $
pub fun file_chmod(path: Text, mode: Text): Bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added mode parameter because users are likely going to want to do more than just set the executable bit.

@@ -70,12 +70,13 @@ pub fun make_executable(path: Text): Bool {
/// Changes the owner of a file.
///
/// If the file doesn't exist, it returns `false`
pub fun change_owner(user: Text, path: Text): Bool {
if file_exist(path) or dir_exist(path) {
pub fun file_chown(path: Text, user: Text): Bool {
Copy link
Contributor Author

@hdwalters hdwalters Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swapped path and user parameters because all other file functions have the filename as the first parameter.

src/tests/stdlib/date_now.ab Outdated Show resolved Hide resolved
@Mte90
Copy link
Member

Mte90 commented Dec 19, 2024

We need to docuument those changes for 0.4.0

@Mte90 Mte90 merged commit 30ffefb into amber-lang:master Dec 19, 2024
1 check passed
@hdwalters hdwalters deleted the rename-stdlib-functions branch December 19, 2024 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants