From e22d901875d3bdfdf6c9888e9beb4bf9147c6b22 Mon Sep 17 00:00:00 2001 From: EmilyGraceSeville7cf Date: Tue, 1 Oct 2024 07:11:15 +1000 Subject: [PATCH] feat(completion): specify default output type for mmdc --- share/completions/mmdc.fish | 2 +- share/functions/__fish_complete_extensions.fish | 16 ++++++++++++++++ share/functions/__fish_print_extensions.fish | 12 ------------ 3 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 share/functions/__fish_complete_extensions.fish delete mode 100644 share/functions/__fish_print_extensions.fish diff --git a/share/completions/mmdc.fish b/share/completions/mmdc.fish index d94857514..68414fd23 100644 --- a/share/completions/mmdc.fish +++ b/share/completions/mmdc.fish @@ -19,7 +19,7 @@ complete -c $command -s h -l height -x \ complete -c $command -s i -l input -r -d 'Specify the input file of a chart' complete -c $command -s o -l output -r \ - -a '(__fish_print_extensions svg md png pdf)' \ + -a '(__fish_complete_extensions svg\tdefault md png pdf)' \ -d 'Specify the output file of a chart' complete -c $command -s e -l outputFormat -x \ diff --git a/share/functions/__fish_complete_extensions.fish b/share/functions/__fish_complete_extensions.fish new file mode 100644 index 000000000..f39adb6ff --- /dev/null +++ b/share/functions/__fish_complete_extensions.fish @@ -0,0 +1,16 @@ +function __fish_complete_extensions \ + --description 'Suggest provided extensions as $argv if the current token ends with a dot' + + set token (commandline -c -t) + + switch "$token" + case '*.' + for extension in $argv + if string match --quiet --regex '\\\t|\t' -- $extension + echo -e "$token$extension" + else + printf "%s%s\n" $token $extension + end + end + end +end diff --git a/share/functions/__fish_print_extensions.fish b/share/functions/__fish_print_extensions.fish deleted file mode 100644 index 2c1c20acc..000000000 --- a/share/functions/__fish_print_extensions.fish +++ /dev/null @@ -1,12 +0,0 @@ -function __fish_print_extensions \ - --description 'Suggest provided extensions as $argv if the current token ends with a dot' - - set token (commandline -c -t) - - switch "$token" - case '*.' - for extension in $argv - printf "%s%s\n" $token $extension - end - end -end