Implement `hugo --theme=[Tab][Tab]` bash completion
authorAnthony Fok <foka@debian.org>
Mon, 10 Aug 2015 00:49:54 +0000 (18:49 -0600)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 11 Aug 2015 13:08:10 +0000 (15:08 +0200)
using the new BashCompSubdirsInDir annotation in spf13/cobra.

commands/hugo.go

index db30148d179ab4343bc313be5e67a3f0635ad6fd..025398f4b7ca30cb7f9878fc56d0a49ccfb015f2 100644 (file)
@@ -112,6 +112,7 @@ func init() {
        // for Bash autocomplete
        validConfigFilenames := []string{"json", "js", "yaml", "yml", "toml", "tml"}
        HugoCmd.PersistentFlags().SetAnnotation("config", cobra.BashCompFilenameExt, validConfigFilenames)
+       HugoCmd.PersistentFlags().SetAnnotation("theme", cobra.BashCompSubdirsInDir, []string{"themes"})
 
        // This message will be shown to Windows users if Hugo is opened from explorer.exe
        cobra.MousetrapHelpText = `