-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflags.go
74 lines (55 loc) · 2.39 KB
/
flags.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2013 Joshua Marsh. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in
// the LICENSE file.
package main
import (
flag "github.com/ogier/pflag"
"path"
)
// WorkingDir is the directory where that should be prepended to all
// the other configurable directories.
var WorkingDir string
// OutputDir is the directory where the results of the program should
// be written to.
var OutputDir string
// EmptyOutputDir is a flag that determines whether or not the
// OutputDir should be cleaned up before writing file to it.
var EmptyOutputDir bool
// TemplateDir is the diretory where the templates can be found.
var TemplateDir string
// BlogDir is the directory where the blog posts can be found.
var BlogDir string
// StaticDir is the directory where static assests can be found.
var StaticDir string
// URL is the url for this site. The RSS feed will use it to generate links.
var URL string
// MaxIndexEntries is the maximum number of entries to display on the
// index page.
var MaxIndexEntries int
func init() {
flag.StringVarP(&WorkingDir, "working-dir", "w", "./",
"The directory where all the other directories reside. This "+
"will be prepended to the rest of the configurable directories.")
flag.StringVarP(&OutputDir, "output-dir", "o", "public",
"The directory where the results should be placed.")
flag.BoolVarP(&EmptyOutputDir, "empty-output-dir", "x", false,
"Before writing to the output-dir, delete anything inside of it.")
flag.StringVarP(&TemplateDir, "template-dir", "t", "templates",
"The directory where the site templates are located.")
flag.StringVarP(&BlogDir, "blog-dir", "b", "blogs",
"The directory where the blogs are located.")
flag.StringVarP(&StaticDir, "static-dir", "s", "static",
"The directory where the static assets are located.")
flag.StringVarP(&URL, "url", "u", "",
"The url to be prepended to link in the RSS feed. Defaults to the value in the channel <link>.")
flag.IntVarP(&MaxIndexEntries, "index-entries", "i", 3,
"The maximum number of entries to display on the index page.")
}
// SetupDirectories is a helper function that prepends the working
// directory to the other directories.
func SetupDirectories() {
OutputDir = path.Join(WorkingDir, OutputDir)
TemplateDir = path.Join(WorkingDir, TemplateDir)
StaticDir = path.Join(WorkingDir, StaticDir)
BlogDir = path.Join(WorkingDir, BlogDir)
}