Repository: kbknapp/clap-rs
Pull request #905 (2017-03-16 19:51:08)

imp: add fish subcommand help support
Adds the `-d help_string` parameter to fish completion is present.

Example output:
```
complete -c mm3d -n "__fish_using_command mm3d" -f -a "Ann" -d "matches points [...]"
```

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/905)
<!-- Reviewable:end -->


coveralls: 
[![Coverage Status](https://coveralls.io/builds/10633659/badge)](https://coveralls.io/builds/10633659)

Changes Unknown when pulling **6e88575eb6c5e2a0d6e241e8d5cd12e7e8f08f32 on peppsac:fish_subcommand_help** into ** on kbknapp:master**.

kbknapp: Thanks for submitting this! I'm good with the change, but have two questions first

* I'm unfamiliar with the `-d` should this be for the the `help_str` which is rarely set and how one would completely override the Auto generated help message or `about` which is nearly always set and simply the short string describing the command / subcommand?

 * How come the diff is so huge? :wink:
kbknapp: Ah ok, I see the whitespace changes for question 2.
peppsac: https://fishshell.com/docs/current/commands.html#complete indicates that `-d` is `a description of what the option and/or option arguments do`, so both `help` and `about` would make sense.

But if `about` is nearly always set I'll modify my commit to use this instead.
Do you want me to split the whitespace changes to a separate commit?
kbknapp: > Do you want me to split the whitespace changes to a separate commit?

No need! 

> But if about is nearly always set I'll modify my commit to use this instead.

Sounds good! 


Patch:
diff --git a/src/completions/fish.rs b/src/completions/fish.rs
index 86f0485c..2e0f36ea 100644
--- a/src/completions/fish.rs
+++ b/src/completions/fish.rs
@@ -95,6 +95,9 @@ fn gen_fish_inner(root_command: &str, comp_gen: &FishGen, parent_cmds: &str, buf
         let mut template = basic_template.clone();
         template.push_str(" -f");
         template.push_str(format!(" -a \"{}\"", &subcommand.p.meta.name).as_str());
+        if let Some(data) = subcommand.p.meta.about {
+            template.push_str(format!(" -d \"{}\"", &data).as_str())
+        }
         buffer.push_str(template.as_str());
         buffer.push_str("\n");
     }


Test patch:
diff --git a/tests/completions.rs b/tests/completions.rs
index e41fc9d1..b429b30a 100644
--- a/tests/completions.rs
+++ b/tests/completions.rs
@@ -4,593 +4,593 @@ extern crate clap;
 use clap::{App, Arg, SubCommand, Shell};
 use regex::Regex;
 
-static BASH: &'static str = r#"_myapp() {
-    local i cur prev opts cmds
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    cmd=""
-    opts=""
-
-    for i in ${COMP_WORDS[@]}
-    do
-        case "${i}" in
-            myapp)
-                cmd="myapp"
-                ;;
-            
-            help)
-                cmd+="__help"
-                ;;
-            test)
-                cmd+="__test"
-                ;;
-            *)
-                ;;
-        esac
-    done
-
-    case "${cmd}" in
-        myapp)
-            opts=" -h -V  --help --version  <file>  test help"
-            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
-                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-                return 0
-            fi
-            case "${prev}" in
-                
-                *)
-                    COMPREPLY=()
-                    ;;
-            esac
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-            ;;
-        
-        myapp__help)
-            opts=" -h -V  --help --version  "
-            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
-                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-                return 0
-            fi
-            case "${prev}" in
-                
-                *)
-                    COMPREPLY=()
-                    ;;
-            esac
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-            ;;
-        myapp__test)
-            opts=" -h -V  --help --version --case  "
-            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
-                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-                return 0
-            fi
-            case "${prev}" in
-                
-                --case)
-                    COMPREPLY=("<case>")
-                    return 0
-                    ;;
-                *)
-                    COMPREPLY=()
-                    ;;
-            esac
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-            ;;
-    esac
-}
-
-complete -F _myapp -o bashdefault -o default myapp
+static BASH: &'static str = r#"_myapp() {
+    local i cur prev opts cmds
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    cmd=""
+    opts=""
+
+    for i in ${COMP_WORDS[@]}
+    do
+        case "${i}" in
+            myapp)
+                cmd="myapp"
+                ;;
+            
+            help)
+                cmd+="__help"
+                ;;
+            test)
+                cmd+="__test"
+                ;;
+            *)
+                ;;
+        esac
+    done
+
+    case "${cmd}" in
+        myapp)
+            opts=" -h -V  --help --version  <file>  test help"
+            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+                return 0
+            fi
+            case "${prev}" in
+                
+                *)
+                    COMPREPLY=()
+                    ;;
+            esac
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+            ;;
+        
+        myapp__help)
+            opts=" -h -V  --help --version  "
+            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+                return 0
+            fi
+            case "${prev}" in
+                
+                *)
+                    COMPREPLY=()
+                    ;;
+            esac
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+            ;;
+        myapp__test)
+            opts=" -h -V  --help --version --case  "
+            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+                return 0
+            fi
+            case "${prev}" in
+                
+                --case)
+                    COMPREPLY=("<case>")
+                    return 0
+                    ;;
+                *)
+                    COMPREPLY=()
+                    ;;
+            esac
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+            ;;
+    esac
+}
+
+complete -F _myapp -o bashdefault -o default myapp
 "#;
 
-static ZSH: &'static str = r#"#compdef myapp
-
-_myapp() {
-    typeset -A opt_args
-    local ret=1
-
-    local context curcontext="$curcontext" state line
-    _arguments -s -S -C \
-"-h[Prints help information]" \
-"--help[Prints help information]" \
-"-V[Prints version information]" \
-"--version[Prints version information]" \
-"1:: :_myapp_commands" \
-"*:: :->myapp" \
-&& ret=0
-    case $state in
-    (myapp)
-        curcontext="${curcontext%:*:*}:myapp-command-$words[1]:"
-        case $line[1] in
-            (test)
-_arguments -s -S -C \
-"--case+[the case to test]" \
-"-h[Prints help information]" \
-"--help[Prints help information]" \
-"-V[Prints version information]" \
-"--version[Prints version information]" \
-&& ret=0
-;;
-(help)
-_arguments -s -S -C \
-"-h[Prints help information]" \
-"--help[Prints help information]" \
-"-V[Prints version information]" \
-"--version[Prints version information]" \
-&& ret=0
-;;
-        esac
-    ;;
-esac
-}
-
-(( $+functions[_myapp_commands] )) ||
-_myapp_commands() {
-    local commands; commands=(
-        "test:tests things" \
-"help:Prints this message or the help of the given subcommand(s)" \
-"FILE:some input file" \
-    )
-    _describe -t commands 'myapp commands' commands "$@"
-}
-(( $+functions[_myapp__help_commands] )) ||
-_myapp__help_commands() {
-    local commands; commands=(
-        
-    )
-    _describe -t commands 'myapp help commands' commands "$@"
-}
-(( $+functions[_myapp__test_commands] )) ||
-_myapp__test_commands() {
-    local commands; commands=(
-        
-    )
-    _describe -t commands 'myapp test commands' commands "$@"
-}
-
+static ZSH: &'static str = r#"#compdef myapp
+
+_myapp() {
+    typeset -A opt_args
+    local ret=1
+
+    local context curcontext="$curcontext" state line
+    _arguments -s -S -C \
+"-h[Prints help information]" \
+"--help[Prints help information]" \
+"-V[Prints version information]" \
+"--version[Prints version information]" \
+"1:: :_myapp_commands" \
+"*:: :->myapp" \
+&& ret=0
+    case $state in
+    (myapp)
+        curcontext="${curcontext%:*:*}:myapp-command-$words[1]:"
+        case $line[1] in
+            (test)
+_arguments -s -S -C \
+"--case+[the case to test]" \
+"-h[Prints help information]" \
+"--help[Prints help information]" \
+"-V[Prints version information]" \
+"--version[Prints version information]" \
+&& ret=0
+;;
+(help)
+_arguments -s -S -C \
+"-h[Prints help information]" \
+"--help[Prints help information]" \
+"-V[Prints version information]" \
+"--version[Prints version information]" \
+&& ret=0
+;;
+        esac
+    ;;
+esac
+}
+
+(( $+functions[_myapp_commands] )) ||
+_myapp_commands() {
+    local commands; commands=(
+        "test:tests things" \
+"help:Prints this message or the help of the given subcommand(s)" \
+"FILE:some input file" \
+    )
+    _describe -t commands 'myapp commands' commands "$@"
+}
+(( $+functions[_myapp__help_commands] )) ||
+_myapp__help_commands() {
+    local commands; commands=(
+        
+    )
+    _describe -t commands 'myapp help commands' commands "$@"
+}
+(( $+functions[_myapp__test_commands] )) ||
+_myapp__test_commands() {
+    local commands; commands=(
+        
+    )
+    _describe -t commands 'myapp test commands' commands "$@"
+}
+
 _myapp "$@""#;
 
-static FISH: &'static str = r#"function __fish_using_command
-    set cmd (commandline -opc)
-    if [ (count $cmd) -eq (count $argv) ]
-        for i in (seq (count $argv))
-            if [ $cmd[$i] != $argv[$i] ]
-                return 1
-            end
-        end
-        return 0
-    end
-    return 1
-end
-
-complete -c myapp -n "__fish_using_command myapp" -s h -l help -d "Prints help information"
-complete -c myapp -n "__fish_using_command myapp" -s V -l version -d "Prints version information"
-complete -c myapp -n "__fish_using_command myapp" -f -a "test"
-complete -c myapp -n "__fish_using_command myapp" -f -a "help"
-complete -c myapp -n "__fish_using_command myapp test" -l case -d "the case to test"
-complete -c myapp -n "__fish_using_command myapp test" -s h -l help -d "Prints help information"
-complete -c myapp -n "__fish_using_command myapp test" -s V -l version -d "Prints version information"
-complete -c myapp -n "__fish_using_command myapp help" -s h -l help -d "Prints help information"
-complete -c myapp -n "__fish_using_command myapp help" -s V -l version -d "Prints version information"
+static FISH: &'static str = r#"function __fish_using_command
+    set cmd (commandline -opc)
+    if [ (count $cmd) -eq (count $argv) ]
+        for i in (seq (count $argv))
+            if [ $cmd[$i] != $argv[$i] ]
+                return 1
+            end
+        end
+        return 0
+    end
+    return 1
+end
+
+complete -c myapp -n "__fish_using_command myapp" -s h -l help -d "Prints help information"
+complete -c myapp -n "__fish_using_command myapp" -s V -l version -d "Prints version information"
+complete -c myapp -n "__fish_using_command myapp" -f -a "test" -d "tests things"
+complete -c myapp -n "__fish_using_command myapp" -f -a "help" -d "Prints this message or the help of the given subcommand(s)"
+complete -c myapp -n "__fish_using_command myapp test" -l case -d "the case to test"
+complete -c myapp -n "__fish_using_command myapp test" -s h -l help -d "Prints help information"
+complete -c myapp -n "__fish_using_command myapp test" -s V -l version -d "Prints version information"
+complete -c myapp -n "__fish_using_command myapp help" -s h -l help -d "Prints help information"
+complete -c myapp -n "__fish_using_command myapp help" -s V -l version -d "Prints version information"
 "#;
 
 #[cfg(not(target_os="windows"))]
-static POWERSHELL: &'static str = r#"
-@('myapp', './myapp') | %{
-    Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
-        param($wordToComplete, $commandAst, $cursorPosition)
-
-        $command = '_myapp'
-        $commandAst.CommandElements |
-            Select-Object -Skip 1 |
-            %{
-                switch ($_.ToString()) {
-
-                    'test' {
-                        $command += '_test'
-                        break
-                    }
-
-                    'help' {
-                        $command += '_help'
-                        break
-                    }
-
-                }
-            }
-
-        $completions = @()
-
-        switch ($command) {
-
-            '_myapp' {
-                $completions = @('test', 'help', '-h', '-V', '--help', '--version')
-            }
-
-            '_myapp_test' {
-                $completions = @('-h', '-V', '--case', '--help', '--version')
-            }
-
-            '_myapp_help' {
-                $completions = @('-h', '-V', '--help', '--version')
-            }
-
-        }
-
-        $completions |
-            ?{ $_ -like "$wordToComplete*" } |
-            Sort-Object |
-            %{ New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_ }
-    }
-}
+static POWERSHELL: &'static str = r#"
+@('myapp', './myapp') | %{
+    Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
+        param($wordToComplete, $commandAst, $cursorPosition)
+
+        $command = '_myapp'
+        $commandAst.CommandElements |
+            Select-Object -Skip 1 |
+            %{
+                switch ($_.ToString()) {
+
+                    'test' {
+                        $command += '_test'
+                        break
+                    }
+
+                    'help' {
+                        $command += '_help'
+                        break
+                    }
+
+                }
+            }
+
+        $completions = @()
+
+        switch ($command) {
+
+            '_myapp' {
+                $completions = @('test', 'help', '-h', '-V', '--help', '--version')
+            }
+
+            '_myapp_test' {
+                $completions = @('-h', '-V', '--case', '--help', '--version')
+            }
+
+            '_myapp_help' {
+                $completions = @('-h', '-V', '--help', '--version')
+            }
+
+        }
+
+        $completions |
+            ?{ $_ -like "$wordToComplete*" } |
+            Sort-Object |
+            %{ New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_ }
+    }
+}
 "#;
 
 #[cfg(target_os="windows")]
-static POWERSHELL: &'static str = r#"
-@('myapp', './myapp', 'myapp.exe', '.\myapp', '.\myapp.exe', './myapp.exe') | %{
-    Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
-        param($wordToComplete, $commandAst, $cursorPosition)
-        $command = '_myapp'
-        $commandAst.CommandElements |
-            Select-Object -Skip 1 |
-            %{
-                switch ($_.ToString()) {
-                    'test' {
-                        $command += '_test'
-                        break
-                    }
-                    'help' {
-                        $command += '_help'
-                        break
-                    }
-                }
-            }
-        $completions = @()
-        switch ($command) {
-            '_myapp' {
-                $completions = @('test', 'help', '-h', '-V', '--help', '--version')
-            }
-            '_myapp_test' {
-                $completions = @('-h', '-V', '--case', '--help', '--version')
-            }
-            '_myapp_help' {
-                $completions = @('-h', '-V', '--help', '--version')
-            }
-        }
-        $completions |
-            ?{ $_ -like "$wordToComplete*" } |
-            Sort-Object |
-            %{ New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_ }
-    }
-}
+static POWERSHELL: &'static str = r#"
+@('myapp', './myapp', 'myapp.exe', '.\myapp', '.\myapp.exe', './myapp.exe') | %{
+    Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
+        param($wordToComplete, $commandAst, $cursorPosition)
+        $command = '_myapp'
+        $commandAst.CommandElements |
+            Select-Object -Skip 1 |
+            %{
+                switch ($_.ToString()) {
+                    'test' {
+                        $command += '_test'
+                        break
+                    }
+                    'help' {
+                        $command += '_help'
+                        break
+                    }
+                }
+            }
+        $completions = @()
+        switch ($command) {
+            '_myapp' {
+                $completions = @('test', 'help', '-h', '-V', '--help', '--version')
+            }
+            '_myapp_test' {
+                $completions = @('-h', '-V', '--case', '--help', '--version')
+            }
+            '_myapp_help' {
+                $completions = @('-h', '-V', '--help', '--version')
+            }
+        }
+        $completions |
+            ?{ $_ -like "$wordToComplete*" } |
+            Sort-Object |
+            %{ New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_ }
+    }
+}
 "#;
 
 #[cfg(not(target_os="windows"))]
-static POWERSHELL_WUS: &'static str = r#"
-@('my_app', './my_app') | %{
-    Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
-        param($wordToComplete, $commandAst, $cursorPosition)
-
-        $command = '_my_app'
-        $commandAst.CommandElements |
-            Select-Object -Skip 1 |
-            %{
-                switch ($_.ToString()) {
-
-                    'test' {
-                        $command += '_test'
-                        break
-                    }
-
-                    'some_cmd' {
-                        $command += '_some_cmd'
-                        break
-                    }
-
-                    'help' {
-                        $command += '_help'
-                        break
-                    }
-
-                }
-            }
-
-        $completions = @()
-
-        switch ($command) {
-
-            '_my_app' {
-                $completions = @('test', 'some_cmd', 'help', '-h', '-V', '--help', '--version')
-            }
-
-            '_my_app_test' {
-                $completions = @('-h', '-V', '--case', '--help', '--version')
-            }
-
-            '_my_app_some_cmd' {
-                $completions = @('-h', '-V', '--config', '--help', '--version')
-            }
-
-            '_my_app_help' {
-                $completions = @('-h', '-V', '--help', '--version')
-            }
-
-        }
-
-        $completions |
-            ?{ $_ -like "$wordToComplete*" } |
-            Sort-Object |
-            %{ New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_ }
-    }
-}
+static POWERSHELL_WUS: &'static str = r#"
+@('my_app', './my_app') | %{
+    Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
+        param($wordToComplete, $commandAst, $cursorPosition)
+
+        $command = '_my_app'
+        $commandAst.CommandElements |
+            Select-Object -Skip 1 |
+            %{
+                switch ($_.ToString()) {
+
+                    'test' {
+                        $command += '_test'
+                        break
+                    }
+
+                    'some_cmd' {
+                        $command += '_some_cmd'
+                        break
+                    }
+
+                    'help' {
+                        $command += '_help'
+                        break
+                    }
+
+                }
+            }
+
+        $completions = @()
+
+        switch ($command) {
+
+            '_my_app' {
+                $completions = @('test', 'some_cmd', 'help', '-h', '-V', '--help', '--version')
+            }
+
+            '_my_app_test' {
+                $completions = @('-h', '-V', '--case', '--help', '--version')
+            }
+
+            '_my_app_some_cmd' {
+                $completions = @('-h', '-V', '--config', '--help', '--version')
+            }
+
+            '_my_app_help' {
+                $completions = @('-h', '-V', '--help', '--version')
+            }
+
+        }
+
+        $completions |
+            ?{ $_ -like "$wordToComplete*" } |
+            Sort-Object |
+            %{ New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_ }
+    }
+}
 "#;
 
 #[cfg(target_os="windows")]
-static POWERSHELL_WUS: &'static str = r#"
-@('my_app', './my_app', 'my_app.exe', '.\my_app', '.\my_app.exe', './my_app.exe') | %{
-    Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
-        param($wordToComplete, $commandAst, $cursorPosition)
-        $command = '_my_app'
-        $commandAst.CommandElements |
-            Select-Object -Skip 1 |
-            %{
-                switch ($_.ToString()) {
-                    'test' {
-                        $command += '_test'
-                        break
-                    }
-                    'some_cmd' {
-                        $command += '_some_cmd'
-                        break
-                    }
-                    'help' {
-                        $command += '_help'
-                        break
-                    }
-                }
-            }
-        $completions = @()
-        switch ($command) {
-            '_my_app' {
-                $completions = @('test', 'some_cmd', 'help', '-h', '-V', '--help', '--version')
-            }
-            '_my_app_test' {
-                $completions = @('-h', '-V', '--case', '--help', '--version')
-            }
-            '_my_app_some_cmd' {
-                $completions = @('-h', '-V', '--config', '--help', '--version')
-            }
-            '_my_app_help' {
-                $completions = @('-h', '-V', '--help', '--version')
-            }
-        }
-        $completions |
-            ?{ $_ -like "$wordToComplete*" } |
-            Sort-Object |
-            %{ New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_ }
-    }
-}
+static POWERSHELL_WUS: &'static str = r#"
+@('my_app', './my_app', 'my_app.exe', '.\my_app', '.\my_app.exe', './my_app.exe') | %{
+    Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
+        param($wordToComplete, $commandAst, $cursorPosition)
+        $command = '_my_app'
+        $commandAst.CommandElements |
+            Select-Object -Skip 1 |
+            %{
+                switch ($_.ToString()) {
+                    'test' {
+                        $command += '_test'
+                        break
+                    }
+                    'some_cmd' {
+                        $command += '_some_cmd'
+                        break
+                    }
+                    'help' {
+                        $command += '_help'
+                        break
+                    }
+                }
+            }
+        $completions = @()
+        switch ($command) {
+            '_my_app' {
+                $completions = @('test', 'some_cmd', 'help', '-h', '-V', '--help', '--version')
+            }
+            '_my_app_test' {
+                $completions = @('-h', '-V', '--case', '--help', '--version')
+            }
+            '_my_app_some_cmd' {
+                $completions = @('-h', '-V', '--config', '--help', '--version')
+            }
+            '_my_app_help' {
+                $completions = @('-h', '-V', '--help', '--version')
+            }
+        }
+        $completions |
+            ?{ $_ -like "$wordToComplete*" } |
+            Sort-Object |
+            %{ New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', $_ }
+    }
+}
 "#;
 
-static ZSH_WUS: &'static str = r#"#compdef my_app
-
-_my_app() {
-    typeset -A opt_args
-    local ret=1
-
-    local context curcontext="$curcontext" state line
-    _arguments -s -S -C \
-"-h[Prints help information]" \
-"--help[Prints help information]" \
-"-V[Prints version information]" \
-"--version[Prints version information]" \
-"1:: :_my_app_commands" \
-"*:: :->my_app" \
-&& ret=0
-    case $state in
-    (my_app)
-        curcontext="${curcontext%:*:*}:my_app-command-$words[1]:"
-        case $line[1] in
-            (test)
-_arguments -s -S -C \
-"--case+[the case to test]" \
-"-h[Prints help information]" \
-"--help[Prints help information]" \
-"-V[Prints version information]" \
-"--version[Prints version information]" \
-&& ret=0
-;;
-(some_cmd)
-_arguments -s -S -C \
-"--config+[the other case to test]" \
-"-h[Prints help information]" \
-"--help[Prints help information]" \
-"-V[Prints version information]" \
-"--version[Prints version information]" \
-&& ret=0
-;;
-(help)
-_arguments -s -S -C \
-"-h[Prints help information]" \
-"--help[Prints help information]" \
-"-V[Prints version information]" \
-"--version[Prints version information]" \
-&& ret=0
-;;
-        esac
-    ;;
-esac
-}
-
-(( $+functions[_my_app_commands] )) ||
-_my_app_commands() {
-    local commands; commands=(
-        "test:tests things" \
-"some_cmd:tests other things" \
-"help:Prints this message or the help of the given subcommand(s)" \
-"FILE:some input file" \
-    )
-    _describe -t commands 'my_app commands' commands "$@"
-}
-(( $+functions[_my_app__help_commands] )) ||
-_my_app__help_commands() {
-    local commands; commands=(
-        
-    )
-    _describe -t commands 'my_app help commands' commands "$@"
-}
-(( $+functions[_my_app__some_cmd_commands] )) ||
-_my_app__some_cmd_commands() {
-    local commands; commands=(
-        
-    )
-    _describe -t commands 'my_app some_cmd commands' commands "$@"
-}
-(( $+functions[_my_app__test_commands] )) ||
-_my_app__test_commands() {
-    local commands; commands=(
-        
-    )
-    _describe -t commands 'my_app test commands' commands "$@"
-}
-
+static ZSH_WUS: &'static str = r#"#compdef my_app
+
+_my_app() {
+    typeset -A opt_args
+    local ret=1
+
+    local context curcontext="$curcontext" state line
+    _arguments -s -S -C \
+"-h[Prints help information]" \
+"--help[Prints help information]" \
+"-V[Prints version information]" \
+"--version[Prints version information]" \
+"1:: :_my_app_commands" \
+"*:: :->my_app" \
+&& ret=0
+    case $state in
+    (my_app)
+        curcontext="${curcontext%:*:*}:my_app-command-$words[1]:"
+        case $line[1] in
+            (test)
+_arguments -s -S -C \
+"--case+[the case to test]" \
+"-h[Prints help information]" \
+"--help[Prints help information]" \
+"-V[Prints version information]" \
+"--version[Prints version information]" \
+&& ret=0
+;;
+(some_cmd)
+_arguments -s -S -C \
+"--config+[the other case to test]" \
+"-h[Prints help information]" \
+"--help[Prints help information]" \
+"-V[Prints version information]" \
+"--version[Prints version information]" \
+&& ret=0
+;;
+(help)
+_arguments -s -S -C \
+"-h[Prints help information]" \
+"--help[Prints help information]" \
+"-V[Prints version information]" \
+"--version[Prints version information]" \
+&& ret=0
+;;
+        esac
+    ;;
+esac
+}
+
+(( $+functions[_my_app_commands] )) ||
+_my_app_commands() {
+    local commands; commands=(
+        "test:tests things" \
+"some_cmd:tests other things" \
+"help:Prints this message or the help of the given subcommand(s)" \
+"FILE:some input file" \
+    )
+    _describe -t commands 'my_app commands' commands "$@"
+}
+(( $+functions[_my_app__help_commands] )) ||
+_my_app__help_commands() {
+    local commands; commands=(
+        
+    )
+    _describe -t commands 'my_app help commands' commands "$@"
+}
+(( $+functions[_my_app__some_cmd_commands] )) ||
+_my_app__some_cmd_commands() {
+    local commands; commands=(
+        
+    )
+    _describe -t commands 'my_app some_cmd commands' commands "$@"
+}
+(( $+functions[_my_app__test_commands] )) ||
+_my_app__test_commands() {
+    local commands; commands=(
+        
+    )
+    _describe -t commands 'my_app test commands' commands "$@"
+}
+
 _my_app "$@""#;
 
-static FISH_WUS: &'static str = r#"function __fish_using_command
-    set cmd (commandline -opc)
-    if [ (count $cmd) -eq (count $argv) ]
-        for i in (seq (count $argv))
-            if [ $cmd[$i] != $argv[$i] ]
-                return 1
-            end
-        end
-        return 0
-    end
-    return 1
-end
-
-complete -c my_app -n "__fish_using_command my_app" -s h -l help -d "Prints help information"
-complete -c my_app -n "__fish_using_command my_app" -s V -l version -d "Prints version information"
-complete -c my_app -n "__fish_using_command my_app" -f -a "test"
-complete -c my_app -n "__fish_using_command my_app" -f -a "some_cmd"
-complete -c my_app -n "__fish_using_command my_app" -f -a "help"
-complete -c my_app -n "__fish_using_command my_app test" -l case -d "the case to test"
-complete -c my_app -n "__fish_using_command my_app test" -s h -l help -d "Prints help information"
-complete -c my_app -n "__fish_using_command my_app test" -s V -l version -d "Prints version information"
-complete -c my_app -n "__fish_using_command my_app some_cmd" -l config -d "the other case to test"
-complete -c my_app -n "__fish_using_command my_app some_cmd" -s h -l help -d "Prints help information"
-complete -c my_app -n "__fish_using_command my_app some_cmd" -s V -l version -d "Prints version information"
-complete -c my_app -n "__fish_using_command my_app help" -s h -l help -d "Prints help information"
-complete -c my_app -n "__fish_using_command my_app help" -s V -l version -d "Prints version information"
+static FISH_WUS: &'static str = r#"function __fish_using_command
+    set cmd (commandline -opc)
+    if [ (count $cmd) -eq (count $argv) ]
+        for i in (seq (count $argv))
+            if [ $cmd[$i] != $argv[$i] ]
+                return 1
+            end
+        end
+        return 0
+    end
+    return 1
+end
+
+complete -c my_app -n "__fish_using_command my_app" -s h -l help -d "Prints help information"
+complete -c my_app -n "__fish_using_command my_app" -s V -l version -d "Prints version information"
+complete -c my_app -n "__fish_using_command my_app" -f -a "test" -d "tests things"
+complete -c my_app -n "__fish_using_command my_app" -f -a "some_cmd" -d "tests other things"
+complete -c my_app -n "__fish_using_command my_app" -f -a "help" -d "Prints this message or the help of the given subcommand(s)"
+complete -c my_app -n "__fish_using_command my_app test" -l case -d "the case to test"
+complete -c my_app -n "__fish_using_command my_app test" -s h -l help -d "Prints help information"
+complete -c my_app -n "__fish_using_command my_app test" -s V -l version -d "Prints version information"
+complete -c my_app -n "__fish_using_command my_app some_cmd" -l config -d "the other case to test"
+complete -c my_app -n "__fish_using_command my_app some_cmd" -s h -l help -d "Prints help information"
+complete -c my_app -n "__fish_using_command my_app some_cmd" -s V -l version -d "Prints version information"
+complete -c my_app -n "__fish_using_command my_app help" -s h -l help -d "Prints help information"
+complete -c my_app -n "__fish_using_command my_app help" -s V -l version -d "Prints version information"
 "#;
 
-static BASH_WUS: &'static str = r#"_my_app() {
-    local i cur prev opts cmds
-    COMPREPLY=()
-    cur="${COMP_WORDS[COMP_CWORD]}"
-    prev="${COMP_WORDS[COMP_CWORD-1]}"
-    cmd=""
-    opts=""
-
-    for i in ${COMP_WORDS[@]}
-    do
-        case "${i}" in
-            my_app)
-                cmd="my_app"
-                ;;
-            
-            help)
-                cmd+="__help"
-                ;;
-            some_cmd)
-                cmd+="__some_cmd"
-                ;;
-            test)
-                cmd+="__test"
-                ;;
-            *)
-                ;;
-        esac
-    done
-
-    case "${cmd}" in
-        my_app)
-            opts=" -h -V  --help --version  <file>  test some_cmd help"
-            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
-                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-                return 0
-            fi
-            case "${prev}" in
-                
-                *)
-                    COMPREPLY=()
-                    ;;
-            esac
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-            ;;
-        
-        my_app__help)
-            opts=" -h -V  --help --version  "
-            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
-                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-                return 0
-            fi
-            case "${prev}" in
-                
-                *)
-                    COMPREPLY=()
-                    ;;
-            esac
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-            ;;
-        my_app__some_cmd)
-            opts=" -h -V  --help --version --config  "
-            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
-                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-                return 0
-            fi
-            case "${prev}" in
-                
-                --config)
-                    COMPREPLY=("<config>")
-                    return 0
-                    ;;
-                *)
-                    COMPREPLY=()
-                    ;;
-            esac
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-            ;;
-        my_app__test)
-            opts=" -h -V  --help --version --case  "
-            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
-                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-                return 0
-            fi
-            case "${prev}" in
-                
-                --case)
-                    COMPREPLY=("<case>")
-                    return 0
-                    ;;
-                *)
-                    COMPREPLY=()
-                    ;;
-            esac
-            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
-            return 0
-            ;;
-    esac
-}
-
-complete -F _my_app -o bashdefault -o default my_app
+static BASH_WUS: &'static str = r#"_my_app() {
+    local i cur prev opts cmds
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    cmd=""
+    opts=""
+
+    for i in ${COMP_WORDS[@]}
+    do
+        case "${i}" in
+            my_app)
+                cmd="my_app"
+                ;;
+            
+            help)
+                cmd+="__help"
+                ;;
+            some_cmd)
+                cmd+="__some_cmd"
+                ;;
+            test)
+                cmd+="__test"
+                ;;
+            *)
+                ;;
+        esac
+    done
+
+    case "${cmd}" in
+        my_app)
+            opts=" -h -V  --help --version  <file>  test some_cmd help"
+            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
+                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+                return 0
+            fi
+            case "${prev}" in
+                
+                *)
+                    COMPREPLY=()
+                    ;;
+            esac
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+            ;;
+        
+        my_app__help)
+            opts=" -h -V  --help --version  "
+            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+                return 0
+            fi
+            case "${prev}" in
+                
+                *)
+                    COMPREPLY=()
+                    ;;
+            esac
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+            ;;
+        my_app__some_cmd)
+            opts=" -h -V  --help --version --config  "
+            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+                return 0
+            fi
+            case "${prev}" in
+                
+                --config)
+                    COMPREPLY=("<config>")
+                    return 0
+                    ;;
+                *)
+                    COMPREPLY=()
+                    ;;
+            esac
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+            ;;
+        my_app__test)
+            opts=" -h -V  --help --version --case  "
+            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+                return 0
+            fi
+            case "${prev}" in
+                
+                --case)
+                    COMPREPLY=("<case>")
+                    return 0
+                    ;;
+                *)
+                    COMPREPLY=()
+                    ;;
+            esac
+            COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+            return 0
+            ;;
+    esac
+}
+
+complete -F _my_app -o bashdefault -o default my_app
 "#;
 
 fn compare(left: &str, right: &str) -> bool {