Enable dirname and filename completion for more flags - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 666ddd237791b56fd048992dca9a27d1af50a10e
DIR parent 0d1d33d7f3a3867a0dc0a43ee02fd5cb84ec17fd
HTML Author: Anthony Fok <foka@debian.org>
Date: Wed, 2 Dec 2015 02:20:55 -0700
Enable dirname and filename completion for more flags
These flags are:
* --source (-s), --cacheDir, --destination (-d) and --logFile
* --completionfile and --dir.
Diffstat:
M commands/genautocomplete.go | 2 ++
M commands/gendoc.go | 3 +++
M commands/genman.go | 3 +++
M commands/hugo.go | 6 +++++-
4 files changed, 13 insertions(+), 1 deletion(-)
---
DIR diff --git a/commands/genautocomplete.go b/commands/genautocomplete.go
@@ -48,4 +48,6 @@ func init() {
genautocompleteCmd.PersistentFlags().StringVarP(&autocompleteTarget, "completionfile", "", "/etc/bash_completion.d/hugo.sh", "Autocompletion file")
genautocompleteCmd.PersistentFlags().StringVarP(&autocompleteType, "type", "", "bash", "Autocompletion type (currently only bash supported)")
+ // For bash-completion
+ genautocompleteCmd.PersistentFlags().SetAnnotation("completionfile", cobra.BashCompFilenameExt, []string{})
}
DIR diff --git a/commands/gendoc.go b/commands/gendoc.go
@@ -60,4 +60,7 @@ for rendering in Hugo.`,
func init() {
gendocCmd.PersistentFlags().StringVar(&gendocdir, "dir", "/tmp/hugodoc/", "the directory to write the doc.")
+
+ // For bash-completion
+ gendocCmd.PersistentFlags().SetAnnotation("dir", cobra.BashCompSubdirsInDir, []string{})
}
DIR diff --git a/commands/genman.go b/commands/genman.go
@@ -42,4 +42,7 @@ in the "man" directory under the current directory.`,
func init() {
genmanCmd.PersistentFlags().StringVar(&genmandir, "dir", "man/", "the directory to write the man pages.")
+
+ // For bash-completion
+ genmanCmd.PersistentFlags().SetAnnotation("dir", cobra.BashCompSubdirsInDir, []string{})
}
DIR diff --git a/commands/hugo.go b/commands/hugo.go
@@ -123,10 +123,14 @@ func init() {
HugoCmd.Flags().BoolVarP(&NoTimes, "noTimes", "", false, "Don't sync modification time of files")
hugoCmdV = HugoCmd
- // for Bash autocomplete
+ // For bash-completion
validConfigFilenames := []string{"json", "js", "yaml", "yml", "toml", "tml"}
HugoCmd.PersistentFlags().SetAnnotation("config", cobra.BashCompFilenameExt, validConfigFilenames)
+ HugoCmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
+ HugoCmd.PersistentFlags().SetAnnotation("cacheDir", cobra.BashCompSubdirsInDir, []string{})
+ HugoCmd.PersistentFlags().SetAnnotation("destination", cobra.BashCompSubdirsInDir, []string{})
HugoCmd.PersistentFlags().SetAnnotation("theme", cobra.BashCompSubdirsInDir, []string{"themes"})
+ HugoCmd.PersistentFlags().SetAnnotation("logFile", cobra.BashCompFilenameExt, []string{})
// This message will be shown to Windows users if Hugo is opened from explorer.exe
cobra.MousetrapHelpText = `