From c1e134f1c28800e5c12126c731cbb5c257aa0c6a Mon Sep 17 00:00:00 2001
From: Anthony Fok <foka@debian.org>
Date: Tue, 15 Dec 2015 23:41:10 -0700
Subject: [PATCH] Add `--source` flag back to `hugo new` command

v0.15 had it, but I removed it inadvertently for 0.16-DEV
in commit 00d04774 in PR #1652.

Also add directory bash-completion for `--source`
for `hugo convert`, `hugo list` and `hugo new`.

See #1624, #1589
---
 commands/convert.go | 1 +
 commands/list.go    | 1 +
 commands/new.go     | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/commands/convert.go b/commands/convert.go
index 9882b006..4fad9070 100644
--- a/commands/convert.go
+++ b/commands/convert.go
@@ -76,6 +76,7 @@ func init() {
 	convertCmd.PersistentFlags().StringVarP(&outputDir, "output", "o", "", "filesystem path to write files to")
 	convertCmd.PersistentFlags().StringVarP(&Source, "source", "s", "", "filesystem path to read files relative from")
 	convertCmd.PersistentFlags().BoolVar(&unsafe, "unsafe", false, "enable less safe operations, please backup first")
+	convertCmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
 }
 
 func convertContents(mark rune) (err error) {
diff --git a/commands/list.go b/commands/list.go
index 207eb9f1..4246b1aa 100644
--- a/commands/list.go
+++ b/commands/list.go
@@ -26,6 +26,7 @@ func init() {
 	listCmd.AddCommand(listDraftsCmd)
 	listCmd.AddCommand(listFutureCmd)
 	listCmd.PersistentFlags().StringVarP(&Source, "source", "s", "", "filesystem path to read files relative from")
+	listCmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
 }
 
 var listCmd = &cobra.Command{
diff --git a/commands/new.go b/commands/new.go
index d465e83f..0eb87dac 100644
--- a/commands/new.go
+++ b/commands/new.go
@@ -41,6 +41,8 @@ func init() {
 	newSiteCmd.Flags().Bool("force", false, "Init inside non-empty directory")
 	newCmd.Flags().StringVarP(&configFormat, "format", "f", "toml", "frontmatter format")
 	newCmd.Flags().StringVarP(&contentType, "kind", "k", "", "Content type to create")
+	newCmd.PersistentFlags().StringVarP(&Source, "source", "s", "", "filesystem path to read files relative from")
+	newCmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
 	newCmd.AddCommand(newSiteCmd)
 	newCmd.AddCommand(newThemeCmd)
 }
-- 
2.30.2