From 50feef2a777af222ad6a73c19dc113e0c100a012 Mon Sep 17 00:00:00 2001 From: James Hegedus Date: Tue, 30 Jun 2020 09:16:35 +1000 Subject: [PATCH] fix: CI formatting use editorconfig (#751) --- .github/workflows/workflow.yml | 5 +- bin/asdf | 28 +++---- completions/asdf.bash | 80 +++++++++---------- lib/asdf.sh | 16 ++-- .../command-export-shell-version.bash | 24 +++--- lib/commands/command-install.bash | 14 ++-- lib/commands/command-local.bash | 16 ++-- lib/commands/command-plugin-list.bash | 22 ++--- lib/commands/command-plugin-test.bash | 28 +++---- lib/utils.bash | 12 +-- 10 files changed, 124 insertions(+), 121 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 7737dcd5..bf779848 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -85,5 +85,8 @@ jobs: - name: Install shfmt run: brew install shfmt + - name: List file to shfmt + run: shfmt -f . + - name: Run shfmt - run: shfmt -d -i 2 -ci . lib/commands/* + run: shfmt -d . diff --git a/bin/asdf b/bin/asdf index efc2c7f1..4341ff02 100755 --- a/bin/asdf +++ b/bin/asdf @@ -26,23 +26,23 @@ find_asdf_cmd() { local asdf_cmd_dir asdf_cmd_dir="$(asdf_dir)/lib/commands" case "$1" in - 'exec' | 'current' | 'env' | 'global' | 'install' | 'latest' | 'local' | \ - 'reshim' | 'uninstall' | 'update' | 'where' | 'which' | \ - 'export-shell-version') - echo "$asdf_cmd_dir/command-$1.bash" 2 - ;; + 'exec' | 'current' | 'env' | 'global' | 'install' | 'latest' | 'local' | \ + 'reshim' | 'uninstall' | 'update' | 'where' | 'which' | \ + 'export-shell-version') + echo "$asdf_cmd_dir/command-$1.bash" 2 + ;; - '' | '--help' | '-h' | 'help') - echo "$asdf_cmd_dir/command-help.bash" 2 - ;; + '' | '--help' | '-h' | 'help') + echo "$asdf_cmd_dir/command-help.bash" 2 + ;; - '--version' | 'version') - echo "$asdf_cmd_dir/command-version.bash" 2 - ;; + '--version' | 'version') + echo "$asdf_cmd_dir/command-version.bash" 2 + ;; - *) - find_cmd "$asdf_cmd_dir" "$@" - ;; + *) + find_cmd "$asdf_cmd_dir" "$@" + ;; esac } diff --git a/completions/asdf.bash b/completions/asdf.bash index 03cc38de..b3fc45d3 100644 --- a/completions/asdf.bash +++ b/completions/asdf.bash @@ -15,51 +15,51 @@ _asdf() { COMPREPLY=() case "$cmd" in - plugin-update) + plugin-update) + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "$plugins --all" -- "$cur")) + ;; + plugin-remove | current | list | list-all) + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "$plugins" -- "$cur")) + ;; + plugin-add) + local available_plugins + available_plugins=$(asdf plugin-list-all 2>/dev/null | awk '{ if ($2 !~ /^\*/) print $1}') + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "$available_plugins" -- "$cur")) + ;; + install) + if [[ "$plugins" == *"$prev"* ]]; then + local versions + versions=$(asdf list-all "$prev" 2>/dev/null) # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$plugins --all" -- "$cur")) - ;; - plugin-remove | current | list | list-all) + COMPREPLY=($(compgen -W "$versions" -- "$cur")) + else # shellcheck disable=SC2207 COMPREPLY=($(compgen -W "$plugins" -- "$cur")) - ;; - plugin-add) - local available_plugins - available_plugins=$(asdf plugin-list-all 2>/dev/null | awk '{ if ($2 !~ /^\*/) print $1}') + fi + ;; + update) + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "--head" -- "$cur")) + ;; + uninstall | where | reshim | local | global | shell) + if [[ "$plugins" == *"$prev"* ]]; then + local versions + versions=$(asdf list "$prev" 2>/dev/null) # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$available_plugins" -- "$cur")) - ;; - install) - if [[ "$plugins" == *"$prev"* ]]; then - local versions - versions=$(asdf list-all "$prev" 2>/dev/null) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$versions" -- "$cur")) - else - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$plugins" -- "$cur")) - fi - ;; - update) + COMPREPLY=($(compgen -W "$versions" -- "$cur")) + else # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "--head" -- "$cur")) - ;; - uninstall | where | reshim | local | global | shell) - if [[ "$plugins" == *"$prev"* ]]; then - local versions - versions=$(asdf list "$prev" 2>/dev/null) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$versions" -- "$cur")) - else - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$plugins" -- "$cur")) - fi - ;; - *) - local cmds='current global help install list list-all local plugin-add plugin-list plugin-list-all plugin-remove plugin-update reshim shell uninstall update where which ' - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$cmds" -- "$cur")) - ;; + COMPREPLY=($(compgen -W "$plugins" -- "$cur")) + fi + ;; + *) + local cmds='current global help install list list-all local plugin-add plugin-list plugin-list-all plugin-remove plugin-update reshim shell uninstall update where which ' + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "$cmds" -- "$cur")) + ;; esac return 0 diff --git a/lib/asdf.sh b/lib/asdf.sh index 53575f36..7ad83741 100644 --- a/lib/asdf.sh +++ b/lib/asdf.sh @@ -7,14 +7,14 @@ asdf() { fi case "$command" in - "shell") - # commands that need to export variables - eval "$(asdf export-shell-version sh "$@")" # asdf_allow: eval - ;; - *) - # forward other commands to asdf script - command asdf "$command" "$@" - ;; + "shell") + # commands that need to export variables + eval "$(asdf export-shell-version sh "$@")" # asdf_allow: eval + ;; + *) + # forward other commands to asdf script + command asdf "$command" "$@" + ;; esac } diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index bcc58730..e3ae5871 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -20,12 +20,12 @@ shell_command() { if [ "$version" = "--unset" ]; then case "$asdf_shell" in - fish) - echo "set -e $version_env_var" - ;; - *) - echo "unset $version_env_var" - ;; + fish) + echo "set -e $version_env_var" + ;; + *) + echo "unset $version_env_var" + ;; esac exit 0 fi @@ -35,12 +35,12 @@ shell_command() { fi case "$asdf_shell" in - fish) - echo "set -gx $version_env_var \"$version\"" - ;; - *) - echo "export $version_env_var=\"$version\"" - ;; + fish) + echo "set -gx $version_env_var \"$version\"" + ;; + *) + echo "export $version_env_var=\"$version\"" + ;; esac } diff --git a/lib/commands/command-install.bash b/lib/commands/command-install.bash index cd4cbb14..5bdf4688 100644 --- a/lib/commands/command-install.bash +++ b/lib/commands/command-install.bash @@ -90,13 +90,13 @@ install_tool_version() { for flag in $flags; do case "$flag" in - "--keep-download") - keep_download=true - shift - ;; - *) - shift - ;; + "--keep-download") + keep_download=true + shift + ;; + *) + shift + ;; esac done diff --git a/lib/commands/command-local.bash b/lib/commands/command-local.bash index 7142904e..50bf390b 100644 --- a/lib/commands/command-local.bash +++ b/lib/commands/command-local.bash @@ -9,14 +9,14 @@ local_command() { while [[ $# -gt 0 ]]; do case $1 in - -p | --parent) - parent="true" - shift # past value - ;; - *) - positional+=("$1") # save it in an array for later - shift # past argument - ;; + -p | --parent) + parent="true" + shift # past value + ;; + *) + positional+=("$1") # save it in an array for later + shift # past argument + ;; esac done diff --git a/lib/commands/command-plugin-list.bash b/lib/commands/command-plugin-list.bash index bb886240..db80b6b7 100644 --- a/lib/commands/command-plugin-list.bash +++ b/lib/commands/command-plugin-list.bash @@ -9,17 +9,17 @@ plugin_list_command() { while [ -n "$*" ]; do case "$1" in - "--urls") - show_repo=true - shift - ;; - "--refs") - show_ref=true - shift - ;; - *) - shift - ;; + "--urls") + show_repo=true + shift + ;; + "--refs") + show_ref=true + shift + ;; + *) + shift + ;; esac done diff --git a/lib/commands/command-plugin-test.bash b/lib/commands/command-plugin-test.bash index 95b888aa..3eb50a7f 100644 --- a/lib/commands/command-plugin-test.bash +++ b/lib/commands/command-plugin-test.bash @@ -13,20 +13,20 @@ plugin_test_command() { while [[ $# -gt 0 ]]; do case $1 in - --asdf-plugin-gitref) - plugin_gitref="$2" - shift # past flag - shift # past value - ;; - --asdf-tool-version) - tool_version="$2" - shift # past flag - shift # past value - ;; - *) - plugin_command_array+=("$1") # save it in an array for later - shift # past argument - ;; + --asdf-plugin-gitref) + plugin_gitref="$2" + shift # past flag + shift # past value + ;; + --asdf-tool-version) + tool_version="$2" + shift # past flag + shift # past value + ;; + *) + plugin_command_array+=("$1") # save it in an array for later + shift # past argument + ;; esac done diff --git a/lib/utils.bash b/lib/utils.bash index fbe69686..c73f54af 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -444,12 +444,12 @@ resolve_symlink() { # If it is a slash we can assume it's root and absolute. Otherwise we treat it # as relative case $resolved_path in - /*) - echo "$resolved_path" - ;; - *) - echo "$PWD/$resolved_path" - ;; + /*) + echo "$resolved_path" + ;; + *) + echo "$PWD/$resolved_path" + ;; esac }