Exchange short flags for long ones

This commit is contained in:
Ilan Cosman 2020-07-20 14:11:59 -07:00
parent 8d356d0d49
commit 46abf0472d
32 changed files with 64 additions and 64 deletions

View File

@ -17,16 +17,16 @@ jobs:
- name: Install dependencies
shell: bash
run: >
sudo apt-get install -y
sudo apt-get install --yes
fish git
curl
python3 python3-venv
- name: Install Tide unattended
run: source "$GITHUB_WORKSPACE/tools/tide_install.fish" && tide_install -lu "$GITHUB_WORKSPACE"
run: source "$GITHUB_WORKSPACE/tools/tide_install.fish" && tide_install --local --unattended "$GITHUB_WORKSPACE"
- name: Install fisher and fishtape
run: tide test -i
run: tide test --install
- name: Run all tests
run: tide test -a
run: tide test --all

View File

@ -23,13 +23,10 @@ tide test -a
### Style Guide
- `if` > `and` or `or`
- Long forms of flags > short forms
- Exception for `set`, please use short forms
- `test` > `[...]`
Prefer pipes over command substitution when convenient.
Ex:
- Long forms of flags > short forms
- Exceptions: `set`, `set_color`, `function foo -a` option, "common knowledge" options for commands like `rm -r`
- Prefer pipes over command substitution when convenient (no extra commands)
### Naming Conventions

View File

@ -1,9 +1,9 @@
set -l subcommands (basename -s '.fish' $__fish_config_dir/functions/_tide_sub_* | string replace '_tide_sub_' '')
set -l uninstallIndex (contains -i uninstall $subcommands)
set -l subcommands (basename --suffix='.fish' $__fish_config_dir/functions/_tide_sub_* | string replace '_tide_sub_' '')
set -l uninstallIndex (contains --index uninstall $subcommands)
set -l subcommandsWithoutUninstall (printf '%s ' $subcommands[1..(math $uninstallIndex-1)] $subcommands[(math $uninstallIndex+1)..-1])
# Disable file completions for the entire command
complete -c tide -f
complete --command tide --no-files
# Offer subcommands (without uninstall) if no subcommand has been given so far
complete -c tide -n "not __fish_seen_subcommand_from $subcommands" -a $subcommandsWithoutUninstall
complete --command tide --condition "not __fish_seen_subcommand_from $subcommands" --arguments=$subcommandsWithoutUninstall

View File

@ -1,4 +1,6 @@
_tide_count_left_prompt_height
_tide_git_prompt_set_vars
_tide_pwd_set_max_length
_tide_pwd_var_change

View File

@ -1,4 +1,4 @@
function _tide_count_left_prompt_height -v tide_left_prompt_items
set -l numberOfNewlines (count (string match -a 'newline' $tide_left_prompt_items))
function _tide_count_left_prompt_height --on-variable tide_left_prompt_items
set -l numberOfNewlines (count (string match --all 'newline' $tide_left_prompt_items))
set -g _tide_left_prompt_height (math 1+$numberOfNewlines)
end

View File

@ -1,3 +1,3 @@
function _tide_decolor -a text
string replace -a $_tide_color_normal '' "$text" | string replace -ar '\e\[[0-9;]*m' ''
string replace --all $_tide_color_normal '' "$text" | string replace --all --regex '\e\[[0-9;]*m' ''
end

View File

@ -1,4 +1,4 @@
function _tide_git_prompt_set_vars -v tide_git_prompt_bg_color
function _tide_git_prompt_set_vars --on-variable tide_git_prompt_bg_color
switch $tide_git_prompt_bg_color
case '' 'normal'
set color ''
@ -6,11 +6,7 @@ function _tide_git_prompt_set_vars -v tide_git_prompt_bg_color
set color (set_color -b $tide_git_prompt_bg_color)
end
set -a vars __fish_git_prompt_char_{cleanstate, dirtystate, invalidstate, stagedstate, stashstate}
set -a vars __fish_git_prompt_char_{stateseparator, untrackedfiles}
set -a vars __fish_git_prompt_char_{upstream_ahead, upstream_behind, upstream_diverged, upstream_equal, upstream_prefix}
for var in $vars
for var in (set --names | string match --regex "__fish_git_prompt_char_.*")
set -g _$var $color$$var
end
end

View File

@ -1,5 +1,5 @@
function _tide_item_jobs
if jobs -q
if jobs --quiet
set_color $tide_jobs_color
printf '%s' $tide_jobs_icon
end

View File

@ -1,5 +1,5 @@
function _tide_item_status
if string match -q --invert '0' $_tide_last_pipestatus # If there is a failure anywhere in the pipestatus
if string match --quiet --invert '0' $_tide_last_pipestatus # If there is a failure anywhere in the pipestatus
if test "$_tide_last_pipestatus" = '1'
if test "$tide_status_always_display_icon" = 'true'
set -g tide_status_bg_color $tide_status_failure_bg_color

View File

@ -27,5 +27,5 @@ function _tide_pwd
end
end
set _tide_pwd_output (string replace -a '/' $colorDirs'/' $_tide_pwd_output)
set _tide_pwd_output (string replace --all '/' $colorDirs'/' $_tide_pwd_output)
end

View File

@ -1,4 +1,4 @@
function _tide_pwd_set_max_length -v tide_pwd_truncate_margin -s WINCH
function _tide_pwd_set_max_length --on-variable tide_pwd_truncate_margin --on-signal WINCH
set -g _tide_pwd_max_length (math $COLUMNS -$tide_pwd_truncate_margin)
_tide_pwd

View File

@ -1,4 +1,4 @@
function _tide_pwd_var_change -v PWD
function _tide_pwd_var_change --on-variable PWD
set -l preDirNumberPwd (string replace $HOME '~' $PWD)
set -l preDirNumberPwdSplit (string split '/' $preDirNumberPwd)

View File

@ -48,9 +48,10 @@ function _tide_menu
end
function _tide_title -a text
set -l midCols (math --scale=0 $fake_columns/2)
set -l midTitle (math --scale=0 (string length $text)/2)
clear
set -l midCols (math -s0 $fake_columns/2)
set -l midTitle (math -s0 (string length $text)/2)
_tide_cursor_right (math $midCols-$midTitle)
set_color -o

View File

@ -15,7 +15,7 @@ function _tide_sub_help -a subcommand
'print this help message'
if contains $subcommand $subcommandList
if functions -q _help_$subcommand
if functions --query _help_$subcommand
_help_$subcommand
else
_tide_generic_help_sub $subcommand
@ -45,13 +45,13 @@ function _tide_sub_help -a subcommand
end
function _tide_get_description -a subcommand
set -l descriptionIndex (contains -i $subcommand $subcommandList)
set -l descriptionIndex (contains --index $subcommand $subcommandList)
printf '%s\n' $descriptionList[$descriptionIndex]
end
function _tide_generic_help_sub -a subcommand
set -l description (_tide_get_description $subcommand)
set -l descriptionFirstLetter (string sub -l 1 $description)
set -l descriptionFirstLetter (string sub --length 1 $description)
set -l upperDescriptionFirstLetter (string upper $descriptionFirstLetter)
printf '%s\n' 'Usage: '$g'tide '$n$b$subcommand$n

View File

@ -32,7 +32,7 @@ function _tide_sub_test
set -l returnStatement 0
if set -q _flag_all
set argv (basename -s '.fish' $testsDir/*)
set argv (basename --suffix='.fish' $testsDir/*)
end
for test in $argv
@ -93,7 +93,7 @@ function _tide_test_help
printf '%s' ' -'$option
printf '%b' '\r'
_tide_cursor_right 20
set -l descriptionIndex (contains -i $option $optionList)
set -l descriptionIndex (contains --index $option $optionList)
printf '%s\n' $descriptionList[$descriptionIndex]
end
end

View File

@ -5,7 +5,7 @@ function _tide_sub_uninstall
end
printf '%s\n' 'Uninstalling tide theme...'
set -l fishPrompt (functions -D fish_prompt)
set -l fishPrompt (functions --details fish_prompt)
# ----------------------------------Remove Files----------------------------------
if test -e $_tide_dir
@ -17,7 +17,7 @@ function _tide_sub_uninstall
source "$__fish_data_dir/functions/fish_prompt.fish"
end
for func in (basename -s '.fish' $_tide_file_list)
for func in (basename --suffix='.fish' $_tide_file_list)
functions -e $func
end

View File

@ -7,7 +7,7 @@ function tide
return 0
end
if functions -q _tide_sub_$subcommand
if functions --query _tide_sub_$subcommand
_tide_sub_$subcommand $argv[2..-1]
else
tide help

View File

@ -18,7 +18,7 @@ function finish
end
function _tide_finish
block -g # Event blocker prevents issues from arising while variables might be undefined etc.
block --global # Event blocker prevents issues from arising while variables might be undefined etc.
if not contains 'prompt_char' $fake_tide_left_prompt_items # Without a prompt_char, the user won't know if a command failed/succeeded
set fake_tide_status_always_display_icon true # Therefore, set the status to always display
@ -42,5 +42,5 @@ function _tide_finish
source "$__fish_config_dir/conf.d/_tide_Ω_init.fish" # Reload important startup variables
block -e
block --erase
end

View File

@ -2,7 +2,7 @@ function classic_prompt_height
_tide_title 'Prompt Height'
_tide_option 1 'One line'
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
set fake_tide_left_prompt_frame_enabled false
set fake_tide_right_prompt_frame_enabled false
_tide_display_prompt
@ -17,13 +17,13 @@ function classic_prompt_height
switch (_tide_menu)
case 1
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
set fake_tide_left_prompt_frame_enabled false
set fake_tide_right_prompt_frame_enabled false
_next_choice 'all/prompt_connection_andor_frame_color'
case 2
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
set -g fake_tide_left_prompt_items $fake_tide_left_prompt_items 'newline'
set fake_tide_left_prompt_frame_enabled true

View File

@ -2,7 +2,7 @@ function lean_prompt_height
_tide_title 'Prompt Height'
_tide_option 1 'One line'
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
_tide_display_prompt
_tide_option 2 'Two lines'
@ -13,10 +13,10 @@ function lean_prompt_height
switch (_tide_menu)
case 1
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
_next_choice 'all/prompt_connection_andor_frame_color'
case 2
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
set -g fake_tide_left_prompt_items $fake_tide_left_prompt_items[1..-2] 'newline' $fake_tide_left_prompt_items[-1]
_next_choice 'lean/lean_prompt_connection'
case r

View File

@ -2,7 +2,7 @@ function pure_prompt_height
_tide_title 'Prompt Height'
_tide_option 1 'One line'
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
_tide_display_prompt
_tide_option 2 'Two lines'
@ -13,10 +13,10 @@ function pure_prompt_height
switch (_tide_menu)
case 1
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
_next_choice 'all/prompt_connection_andor_frame_color'
case 2
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
set -g fake_tide_left_prompt_items $fake_tide_left_prompt_items[1..-2] 'newline' $fake_tide_left_prompt_items[-1]
_next_choice 'all/prompt_connection_andor_frame_color'
case r

View File

@ -2,7 +2,7 @@ function rainbow_prompt_height
_tide_title 'Prompt Height'
_tide_option 1 'One line'
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
set fake_tide_left_prompt_frame_enabled false
set fake_tide_right_prompt_frame_enabled false
_tide_display_prompt
@ -17,12 +17,12 @@ function rainbow_prompt_height
switch (_tide_menu)
case 1
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
set fake_tide_left_prompt_frame_enabled false
set fake_tide_right_prompt_frame_enabled false
_next_choice 'all/prompt_connection_andor_frame_color'
case 2
set -e fake_tide_left_prompt_items[(contains -i 'newline' $fake_tide_left_prompt_items)]
set -e fake_tide_left_prompt_items[(contains --index 'newline' $fake_tide_left_prompt_items)]
set -g fake_tide_left_prompt_items $fake_tide_left_prompt_items 'newline'
set fake_tide_left_prompt_frame_enabled true
set fake_tide_right_prompt_frame_enabled true

View File

@ -12,7 +12,6 @@ _set fake_tide_left_prompt_item_separator_same_color ''
_set fake_tide_left_prompt_item_separator_diff_color ''
_set fake_tide_left_prompt_item_separator_same_color_color 949494
_set fake_tide_right_prompt_item_separator_same_color_color 949494
_set fake_tide_left_prompt_prefix ''
_set fake_tide_left_prompt_suffix ''
@ -26,6 +25,8 @@ _set fake_tide_right_prompt_pad_items true
_set fake_tide_right_prompt_item_separator_same_color ''
_set fake_tide_right_prompt_item_separator_diff_color ''
_set fake_tide_right_prompt_item_separator_same_color_color 949494
_set fake_tide_right_prompt_prefix ''
_set fake_tide_right_prompt_suffix ''

View File

@ -12,7 +12,6 @@ _set fake_tide_left_prompt_item_separator_same_color ' '
_set fake_tide_left_prompt_item_separator_diff_color ' '
_set fake_tide_left_prompt_item_separator_same_color_color 949494
_set fake_tide_right_prompt_item_separator_same_color_color 949494
_set fake_tide_left_prompt_prefix ''
_set fake_tide_left_prompt_suffix ' '
@ -26,6 +25,8 @@ _set fake_tide_right_prompt_pad_items false
_set fake_tide_right_prompt_item_separator_same_color ' '
_set fake_tide_right_prompt_item_separator_diff_color ' '
_set fake_tide_right_prompt_item_separator_same_color_color 949494
_set fake_tide_right_prompt_prefix ' '
_set fake_tide_right_prompt_suffix ''

View File

@ -12,7 +12,6 @@ _set fake_tide_left_prompt_item_separator_same_color ' '
_set fake_tide_left_prompt_item_separator_diff_color ' '
_set fake_tide_left_prompt_item_separator_same_color_color 949494
_set fake_tide_right_prompt_item_separator_same_color_color 949494
_set fake_tide_left_prompt_prefix ''
_set fake_tide_left_prompt_suffix ' '
@ -26,6 +25,8 @@ _set fake_tide_right_prompt_pad_items false
_set fake_tide_right_prompt_item_separator_same_color ' '
_set fake_tide_right_prompt_item_separator_diff_color ' '
_set fake_tide_right_prompt_item_separator_same_color_color 949494
_set fake_tide_right_prompt_prefix ' '
_set fake_tide_right_prompt_suffix ''

View File

@ -12,7 +12,6 @@ _set fake_tide_left_prompt_item_separator_same_color ''
_set fake_tide_left_prompt_item_separator_diff_color ''
_set fake_tide_left_prompt_item_separator_same_color_color 949494
_set fake_tide_right_prompt_item_separator_same_color_color 949494
_set fake_tide_left_prompt_prefix ''
_set fake_tide_left_prompt_suffix ''
@ -26,6 +25,8 @@ _set fake_tide_right_prompt_pad_items true
_set fake_tide_right_prompt_item_separator_same_color ''
_set fake_tide_right_prompt_item_separator_diff_color ''
_set fake_tide_right_prompt_item_separator_same_color_color 949494
_set fake_tide_right_prompt_prefix ''
_set fake_tide_right_prompt_suffix ''

View File

@ -1,4 +1,4 @@
function _fake_tide_count_left_prompt_height -v fake_tide_left_prompt_items
set -l numberOfNewlines (count (string match -a 'newline' $fake_tide_left_prompt_items))
set -l numberOfNewlines (count (string match --all 'newline' $fake_tide_left_prompt_items))
set -g _fake_tide_left_prompt_height (math 1+$numberOfNewlines)
end

View File

@ -8,4 +8,4 @@ end
@test 'None' (_context) -z
@test 'SSH' (set -g SSH_TTY 'true'; _context) = $USER'@'$hostname
@test 'Root' (_tide_decolor (sudo fish -c "source $sourceFile;_tide_item_context")) = 'root@'$hostname
@test 'Root' (_tide_decolor (sudo fish --command="source $sourceFile;_tide_item_context")) = 'root@'$hostname

View File

@ -9,7 +9,7 @@ end
# Unwritable directories
sudo mkdir -p ~/unwritable/dir # Uses sudo to make the dir unwritable
sudo mkdir --parents ~/unwritable/dir # Uses sudo to make the dir unwritable
set -lx tide_pwd_unwritable_icon ''
@ -26,7 +26,7 @@ set -lx tide_pwd_unwritable_icon
# Normal directories
mkdir -p ~/normal/dir
mkdir --parents ~/normal/dir
@test '~' (_pwd ~) = '~'
@test '~/normal' (_pwd ~/normal) = '~/normal'
@ -37,7 +37,7 @@ rm -rf ~/normal
# Long directories
set -l longDir ~/alfa/bravo/charlie/delta/echo/foxtrot/golf/hotel/inda/juliett/kilo/lima/mike/november/oscar/papa
mkdir -p $longDir
mkdir --parents $longDir
@test 'Long dir' (_pwd "$longDir") = '~/a/b/c/d/e/f/g/hotel/inda/juliett/kilo/lima/mike/november/oscar/papa'

View File

@ -6,7 +6,7 @@ end
set -l dir ~/python_project
mkdir -p $dir
mkdir --parents $dir
cd $dir
@test 'nothing' (_virtual_env) -z

View File

@ -20,7 +20,7 @@ function _tide_actual_install
if set -q _flag_local
cp -rf "$location" "$tempDir"
else
git clone -q --depth 1 -b $location https://github.com/IlanCosman/tide.git $tempDir
git clone --quiet --depth 1 --branch $location https://github.com/IlanCosman/tide.git $tempDir
end
for dir in completions conf.d functions tide_theme

View File

@ -17,7 +17,7 @@ function tide_install
set -a flags '-l'
else
curl -s "https://raw.githubusercontent.com/IlanCosman/tide/$location/tools/_tide_actual_install.fish" | source
curl --silent "https://raw.githubusercontent.com/IlanCosman/tide/$location/tools/_tide_actual_install.fish" | source
end
_tide_actual_install $flags $argv