summaryrefslogtreecommitdiffstats
path: root/hugolib/planner.go
blob: 160479c4c29cbf4bec20d365b5a1bd69fdebcc9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package hugolib

import (
	"fmt"
	"io"
)

func (s *Site) ShowPlan(out io.Writer) (err error) {
	if s.Source == nil || len(s.Source.Files()) <= 0 {
		fmt.Fprintf(out, "No source files provided.\n")
	}

	for _, p := range s.Pages {
		fmt.Fprintf(out, "%s\n", p.FileName)
		fmt.Fprintf(out, " canonical => ")
		if s.Target == nil {
			fmt.Fprintf(out, "%s\n", "!no target specified!")
			continue
		}

		trns, err := s.Target.Translate(p.OutFile)
		if err != nil {
			return err
		}
		fmt.Fprintf(out, "%s\n", trns)

		if s.Alias == nil {
			continue
		}

		for _, alias := range p.Aliases {
			aliasTrans, err := s.Alias.Translate(alias)
			if err != nil {
				return err
			}
			fmt.Fprintf(out, " %s => %s\n", alias, aliasTrans)
		}
	}
	return
}