From 31fd5b3b6489b1a142ec89d30f2fabe06867d96c Mon Sep 17 00:00:00 2001 From: EmilyGraceSeville7cf Date: Tue, 1 Oct 2024 05:44:35 +1000 Subject: [PATCH] feat(completion): support mmdc tool --- share/completions/mmdc.fish | 50 +++++++++++++++++++ .../functions/__fish_complete_extension.fish | 12 +++++ 2 files changed, 62 insertions(+) create mode 100644 share/completions/mmdc.fish create mode 100644 share/functions/__fish_complete_extension.fish diff --git a/share/completions/mmdc.fish b/share/completions/mmdc.fish new file mode 100644 index 000000000..ec4ca45f2 --- /dev/null +++ b/share/completions/mmdc.fish @@ -0,0 +1,50 @@ +set -l command mmdc + +complete -c $command -f + +complete -c $command -s h -l help -d 'Show help' +complete -c $command -s V -l version -d 'Show version' + +complete -c $command -s t -l theme -x \ + -a 'default\tdefault forest dark neutral' \ + -d 'Specify the theme of a chart' + +complete -c $command -s w -l width -x \ + -a '800\tdefault' \ + -d 'Specify the width of a chart' + +complete -c $command -s h -l height -x \ + -a '600\tdefault' \ + -d 'Specify the height of a chart' + +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_complete_extension svg md png pdf)' \ + -d 'Specify the output file of a chart' + +complete -c $command -s e -l outputFormat -x \ + -a 'svg png pdf' \ + -d 'Specify the output format of a chart' + +complete -c $command -s b -l backgroundColor -x \ + -a 'white\tdefault transparent' \ + -d 'Specify the background color of a chart' + +complete -c $command -s c -l configFile -r \ + -d 'Specify the configuration file of Mermaid' + +complete -c $command -s C -l cssFile -r \ + -d 'Specify the CSS file of a Mermaid' + +complete -c $command -s I -l svgId -x \ + -d 'Specify the SVG identifier of a SVG element' + +complete -c $command -s s -l scale -x \ + -a '1\tdefault' \ + -d 'Specify the scale factor of a chart' + +complete -c $command -s f -l pdfFit -d 'Whether to scale the PDF to fit a chart' +complete -c $command -s q -l quiet -d 'Whether to suppress output of a chart' + +complete -c $command -s p -l puppeteerConfigFile -r \ + -d 'Specify the configuration file of Puppeteer' diff --git a/share/functions/__fish_complete_extension.fish b/share/functions/__fish_complete_extension.fish new file mode 100644 index 000000000..01de47366 --- /dev/null +++ b/share/functions/__fish_complete_extension.fish @@ -0,0 +1,12 @@ +function __fish_complete_extension \ + --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 \ No newline at end of file