Skip to content
This repository was archived by the owner on Jul 29, 2021. It is now read-only.

Commit ef2a575

Browse files
committed
change template flag to be a file
1 parent 844d7c5 commit ef2a575

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"flag"
1616
"fmt"
1717
"go/build"
18+
"io/ioutil"
1819
"log"
1920
"os"
2021
"path"
@@ -37,7 +38,7 @@ var (
3738
// layout control
3839
tabWidth = flag.Int("tabwidth", 4, "tab width")
3940
showTimestamps = flag.Bool("timestamps", false, "show timestamps with directory listings")
40-
altPkgTemplate = flag.String("template", "", "alternate template")
41+
altPkgTemplate = flag.String("template", "", "path to an alternate template file")
4142
showPlayground = flag.Bool("play", false, "enable playground in web interface")
4243
showExamples = flag.Bool("ex", false, "show examples in command line mode")
4344
declLinks = flag.Bool("links", true, "link identifiers to their declarations")
@@ -123,7 +124,11 @@ func main() {
123124
pres.HTMLMode = false
124125

125126
if *altPkgTemplate != "" {
126-
pres.PackageText = readTemplate("package.txt", *altPkgTemplate)
127+
buf, err := ioutil.ReadFile(*altPkgTemplate)
128+
if err != nil {
129+
log.Fatal(err)
130+
}
131+
pres.PackageText = readTemplate("package.txt", string(buf))
127132
} else {
128133
pres.PackageText = readTemplate("package.txt", pkgTemplate)
129134
}

0 commit comments

Comments
 (0)