diff --git a/homebrew/brew_utils b/homebrew/brew_utils index 21e7cd0..d35991a 100644 --- a/homebrew/brew_utils +++ b/homebrew/brew_utils @@ -16,8 +16,8 @@ function brew_prefix end end -function brew_tap - brew tap "$argv[1]" &>/dev/null +function brew_tap -a $tap + brew tap "$tap" &>/dev/null end function brew_update @@ -30,12 +30,7 @@ end # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function brew_install - set -f formula_readable_name $argv[1] - set -f formula $argv[2] - set -f arguments $argv[3] - set -f tap_value $argv[4] - +function brew_install -a $formula_readable_name $formula $arguments $tap_value # Check that Homebrew is installed if ! cmd_exists "brew" print_error "$formula_readable_name ('Homebrew' is not installed)" diff --git a/homebrew/os/pref.sh b/homebrew/os/pref.sh deleted file mode 100755 index e69de29..0000000 diff --git a/script/dot b/script/dot index 322d033..f5c9ed2 100755 --- a/script/dot +++ b/script/dot @@ -21,10 +21,7 @@ end # Symlink Dotfiles # ################################################################################ -function link_file - set -f src $argv[1] - set -f dst $argv[2] - +function link_file -a $src $dst set -f action if [ -f "$dst" ] || [ -d "$dst" ] || [ -L "$dst" ] @@ -91,10 +88,10 @@ function link_file end end -function make_dst +function make_dst -a $src set -l path (string replace -a '/' '\/' "$DOT") set -l regex (string join '' '^' "$path" '\/[a-zA-Z]+\/(.+)\.symlink$') - set -l dst (string replace -r $regex '$1' "$argv[1]") + set -l dst (string replace -r $regex '$1' "$src") printf '%s' "$HOME/$dst" end diff --git a/script/utils b/script/utils index 710e206..b36f819 100755 --- a/script/utils +++ b/script/utils @@ -2,57 +2,57 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function print_in_color +function print_in_color -a $color $text printf '%b' \ - "$(tput setaf $argv[2] 2> /dev/null)" \ - $argv[1] \ + "$(tput setaf $color 2> /dev/null)" \ + $text \ "$(tput sgr0 2> /dev/null)" end -function print_in_red - print_in_color $argv[1] 1 +function print_in_red -a $text + print_in_color $text 1 end -function print_in_yellow - print_in_color $argv[1] 3 +function print_in_yellow -a $text + print_in_color $text 3 end -function print_in_green - print_in_color $argv[1] 2 +function print_in_green -a $text + print_in_color $text 2 end -function print_in_purple - print_in_color $argv[1] 5 +function print_in_purple -a $text + print_in_color $text 5 end -function print_title - print_in_purple "\n • $argv[1]\n\n" +function print_title -a $text + print_in_purple "\n • $text\n\n" end -function print_success - print_in_green " [✔] $argv[1]\n" +function print_success -a $text + print_in_green " [✔] $text\n" end -function print_warning - print_in_yellow " [!] $argv[1]\n" +function print_warning -a $text + print_in_yellow " [!] $text\n" end -function print_error - print_in_red " [✖] $argv[1] $argv[2]\n" +function print_error -a $text $text2 + print_in_red " [✖] $text $text2\n" end -function print_question - print_in_yellow " [?] $argv[1]\n" +function print_question -a $text + print_in_yellow " [?] $text\n" end -function print_result - if [ "$argv[1]" -eq 0 ] - print_success $argv[2] +function print_result -a $exit_code $text + if [ "$exit_code" -eq 0 ] + print_success $text else - print_error $argv[2] + print_error $text end - return $argv[1] + return $exit_code end function print_error_stream @@ -63,15 +63,11 @@ end # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function show_spinner +function show_spinner -a $pid $cmds $msg set -l frames '/-\|' set -l number_of_frames (string length $FRAMES) - set -l pid $argv[1] - set -l cmds $argv[2] - set -l msg $argv[3] - set -l i 0 set -l frame_text "" @@ -95,9 +91,9 @@ end # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function set_trap - trap -p "$argv[1]" | grep "$argv[2]" &> /dev/null \ - || trap "$argv[2]" "$argv[1]" +function set_trap -a $sig $func + trap -p "$sig" | grep "$func" &> /dev/null \ + || trap "$func" "$sig" end function kill_all_subproccesses @@ -111,9 +107,8 @@ end # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function execute - set -l cmds $argv[1] - set -q $argv[2] and set -l msg $argv[2] or set -l msg $argv[1] +function execute -a $cmds + set -q $argv[2] and set -l msg $argv[2] or set -l msg "$cmds" set -l tmp_file "$(mktmp /tmp/XXXXX)"