diff options
Diffstat (limited to 'commands/list.go')
-rw-r--r-- | commands/list.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/commands/list.go b/commands/list.go index 2e85a8765..b3af0ef63 100644 --- a/commands/list.go +++ b/commands/list.go @@ -33,22 +33,25 @@ var listCmd = &cobra.Command{ Long: `Listing out various types of content. List requires a subcommand, e.g. ` + "`hugo list drafts`.", - Run: nil, + RunE: nil, } var listDraftsCmd = &cobra.Command{ Use: "drafts", Short: "List all drafts", Long: `List all of the drafts in your content directory.`, - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { + + if err := InitializeConfig(); err != nil { + return err + } - InitializeConfig() viper.Set("BuildDrafts", true) site := &hugolib.Site{} if err := site.Process(); err != nil { - fmt.Println("Error Processing Source Content", err) + return newSystemError("Error Processing Source Content", err) } for _, p := range site.Pages { @@ -58,6 +61,8 @@ var listDraftsCmd = &cobra.Command{ } + return nil + }, } @@ -66,15 +71,18 @@ var listFutureCmd = &cobra.Command{ Short: "List all posts dated in the future", Long: `List all of the posts in your content directory which will be posted in the future.`, - Run: func(cmd *cobra.Command, args []string) { + RunE: func(cmd *cobra.Command, args []string) error { + + if err := InitializeConfig(); err != nil { + return err + } - InitializeConfig() viper.Set("BuildFuture", true) site := &hugolib.Site{} if err := site.Process(); err != nil { - fmt.Println("Error Processing Source Content", err) + return newSystemError("Error Processing Source Content", err) } for _, p := range site.Pages { @@ -84,5 +92,7 @@ posted in the future.`, } + return nil + }, } |