Просмотр исходного кода

ci: include bash completion script in treefmt and fixed shellcheck formatting in completion script

9glenda 2 лет назад
Родитель
Сommit
9a9614f1da
2 измененных файлов с 15 добавлено и 12 удалено
  1. 12 12
      completions/bash/eza
  2. 3 0
      treefmt.nix

+ 12 - 12
completions/bash/eza

@@ -1,5 +1,5 @@
-_eza()
-{
+# shellcheck shell=bash
+_eza() {
     cur=${COMP_WORDS[COMP_CWORD]}
     prev=${COMP_WORDS[COMP_CWORD-1]}
 
@@ -9,27 +9,27 @@ _eza()
             ;;
 
         --colour)
-            COMPREPLY=( $( compgen -W 'always auto never' -- "$cur" ) )
+            mapfile -t COMPREPLY < <(compgen -W 'always auto never' -- "$cur")
             return
             ;;
 
         -L|--level)
-            COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) )
+            mapfile -t COMPREPLY < <(compgen -W '{0..9}' -- "$cur")
             return
             ;;
 
         -s|--sort)
-            COMPREPLY=( $( compgen -W 'name filename Name Filename size filesize extension Extension date time modified changed accessed created type inode oldest newest age none --' -- "$cur" ) )
+            mapfile -t COMPREPLY < <(compgen -W 'name filename Name Filename size filesize extension Extension date time modified changed accessed created type inode oldest newest age none --' -- "$cur")
             return
             ;;
 
         -t|--time)
-            COMPREPLY=( $( compgen -W 'modified changed accessed created --' -- "$cur" ) )
+            mapfile -t COMPREPLY < <(compgen -W 'modified changed accessed created --' -- "$cur")
             return
             ;;
 
         --time-style)
-            COMPREPLY=( $( compgen -W 'default iso long-iso full-iso relative --' -- "$cur" ) )
+            mapfile -t COMPREPLY < <(compgen -W 'default iso long-iso full-iso relative --' -- "$cur")
             return
             ;;
     esac
@@ -38,14 +38,14 @@ _eza()
         # _parse_help doesn’t pick up short options when they are on the same line than long options
         --*)
             # colo[u]r isn’t parsed correctly so we filter these options out and add them by hand
-            parse_help=$( eza --help | grep -oE ' (--[[:alnum:]@-]+)' | tr -d ' ' | grep -v '\--colo' )
-            completions=$( echo '--color --colour --color-scale --colour-scale' $parse_help )
-            COMPREPLY=( $( compgen -W "$completions" -- "$cur" ) )
+            parse_help=$(eza --help | grep -oE ' (--[[:alnum:]@-]+)' | tr -d ' ' | grep -v '\--colo')
+            completions=$(echo '--color --colour --color-scale --colour-scale' "$parse_help")
+            mapfile -t COMPREPLY < <(compgen -W "$completions" -- "$cur")
             ;;
 
         -*)
-            completions=$( eza --help | grep -oE ' (-[[:alnum:]@])' | tr -d ' ' )
-            COMPREPLY=( $( compgen -W "$completions" -- "$cur" ) )
+            completions=$(eza --help | grep -oE ' (-[[:alnum:]@])' | tr -d ' ')
+            mapfile -t COMPREPLY < <(compgen -W "$completions" -- "$cur")
             ;;
 
         *)

+ 3 - 0
treefmt.nix

@@ -5,4 +5,7 @@
     rustfmt.enable = true;
     shellcheck.enable = true;
   };
+  settings = {
+    formatter.shellcheck.includes = ["*.sh" "./completions/bash/eza"];
+  };
 }