Repository: kbknapp/clap-rs (rust)

Issue:
Redundant code in Zsh completion when there are no subcommands
<!--
Please use the following template to assist with creating an issue and to ensure a speedy resolution. If an area is not applicable, feel free to delete the area or mark with `N/A`
-->

### Rust Version

`rustc 1.23.0 (766bd11c8 2018-01-01)`

### Affected Version of clap

`2.29.0`

### Expected Behavior Summary
There shouldn't be redundant code in the generated Zsh completion code.

### Actual Behavior Summary
There is some redundant code when there are no sub-commands.

**Generated from the sample:**
```zsh
#compdef clap-test

_clap-test() {
    typeset -A opt_args
    local ret=1

    local context curcontext="$curcontext" state line
    _arguments -s -S -C \
'--completions[]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
    
}

(( $+functions[_clap-test_commands] )) ||
_clap-test_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'clap-test commands' commands "$@"
}
(( $+functions[_clap-test_commands] )) ||
_clap-test_commands() {
    local commands; commands=(
        
    )
    _describe -t commands 'clap-test commands' commands "$@"
}

_clap-test "$@"
```

Notice the double `_clap-test_commands` part.

### Steps to Reproduce the issue
1. Build the sample.
2. Run `cargo run -- --completions`.
3. Check the output.

### Sample Code or Link to Sample Code
```rust
extern crate clap;

use std::io;
use clap::{App, Arg, Shell};

fn build_cli() -> App<'static, 'static> {
    App::new("clap-test")
        .arg(Arg::with_name("completions")
            .long("completions"))
}

fn main() {
    let matches = build_cli().get_matches();

    if matches.is_present("completions") {
        build_cli().gen_completions_to("clap-test", Shell::Zsh, &mut io::stdout())
    }
}
```

### Debug output
[clap-debug.txt](https://github.com/kbknapp/clap-rs/files/1608772/clap-debug.txt)


Pull request description:
fix(completions/zsh.zsh): Remove redundant code from output
Fixes #1142

(Hopefully didn't break anything, the tests didn't break at least)

<!-- 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/1144)
<!-- Reviewable:end -->


Patch:
diff --git a/src/completions/mod.rs b/src/completions/mod.rs
index 026b4493..742c6161 100644
--- a/src/completions/mod.rs
+++ b/src/completions/mod.rs
@@ -91,12 +91,7 @@ pub fn subcommands_of(p: &Parser) -> Vec<(String, String)> {
         p.has_subcommands()
     );
     if !p.has_subcommands() {
-        let mut ret = vec![
-            (
-                p.meta.name.clone(),
-                p.meta.bin_name.as_ref().unwrap().clone(),
-            ),
-        ];
+        let mut ret = vec![];
         debugln!("subcommands_of: Looking for aliases...");
         if let Some(ref aliases) = p.meta.aliases {
             for &(n, _) in aliases {


Test patch:
diff --git a/tests/completions.rs b/tests/completions.rs
index 91c454b1..84018c8b 100644
--- a/tests/completions.rs
+++ b/tests/completions.rs
@@ -675,13 +675,6 @@ _my_app() {
     
 }
 
-(( $+functions[_my_app_commands] )) ||
-_my_app_commands() {
-    local commands; commands=(
-        
-    )
-    _describe -t commands 'my_app commands' commands "$@"
-}
 (( $+functions[_my_app_commands] )) ||
 _my_app_commands() {
     local commands; commands=(