ref: 5461a5e03d1d7c2e3179abea88aef48e62f413e5
parent: 51f7cd9bdeb5cec48c1ad24786120ae7fce0c404
author: Hanchen Wang <[email protected]>
date: Wed May 11 06:11:23 EDT 2016
commands: Add listExpiredCmd for expired pages
--- a/commands/list.go
+++ b/commands/list.go
@@ -25,6 +25,7 @@
func init() {
listCmd.AddCommand(listDraftsCmd)
listCmd.AddCommand(listFutureCmd)
+ listCmd.AddCommand(listExpiredCmd)
listCmd.PersistentFlags().StringVarP(&source, "source", "s", "", "filesystem path to read files relative from")
listCmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
}
@@ -89,6 +90,37 @@
for _, p := range site.Pages {
if p.IsFuture() {
+ fmt.Println(filepath.Join(p.File.Dir(), p.File.LogicalName()))
+ }
+
+ }
+
+ return nil
+
+ },
+}
+
+var listExpiredCmd = &cobra.Command{
+ Use: "expired",
+ Short: "List all posts already expired",
+ Long: `List all of the posts in your content directory which has already
+expired.`,
+ RunE: func(cmd *cobra.Command, args []string) error {
+
+ if err := InitializeConfig(); err != nil {
+ return err
+ }
+
+ viper.Set("BuildExpired", true)
+
+ site := &hugolib.Site{}
+
+ if err := site.Process(); err != nil {
+ return newSystemError("Error Processing Source Content", err)
+ }
+
+ for _, p := range site.Pages {
+ if p.IsExpired() {
fmt.Println(filepath.Join(p.File.Dir(), p.File.LogicalName()))
}