mirror of
https://github.com/thebaer/squigglelog
synced 2018-07-20 10:45:21 +00:00
Add -o flag and output to public_html
This commit is contained in:
parent
e75f931290
commit
d060b2f1c4
@ -13,10 +13,11 @@ import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
var outputPath string = os.Getenv("HOME") + "/public_html/"
|
||||
const entriesPath = "./entries/"
|
||||
const templatesPath = "./templates/"
|
||||
const outputPath = "./html/"
|
||||
const defaultTemplateFile = "log"
|
||||
const defaultOutFile = "~log"
|
||||
|
||||
type Entry struct {
|
||||
Date string
|
||||
@ -48,11 +49,12 @@ func loadEntry(rawDate string) (*Entry, error) {
|
||||
|
||||
func main() {
|
||||
fmt.Println()
|
||||
fmt.Println(" ~log generator v1.0")
|
||||
fmt.Println(" ~log generator v1.1")
|
||||
fmt.Println()
|
||||
|
||||
// Get any arguments
|
||||
templateFilePtr := flag.String("template", defaultTemplateFile, "Tildelog template file (defined name).")
|
||||
templateFilePtr := flag.String("t", defaultTemplateFile, "Squigglelog template file (defined name).")
|
||||
outFilePtr := flag.String("o", defaultOutFile, "Squigglelog template file (defined name).")
|
||||
flag.Parse()
|
||||
|
||||
c := configuration()
|
||||
@ -80,9 +82,9 @@ func main() {
|
||||
|
||||
fmt.Printf("Using template %s...\n", *templateFilePtr)
|
||||
|
||||
generateLog(entries, *templateFilePtr)
|
||||
generateLog(entries, *templateFilePtr, *outFilePtr)
|
||||
|
||||
fmt.Printf("Finished! Saved to %slog.html\n", outputPath)
|
||||
fmt.Printf("Finished! Saved to %s%s.html\n", outputPath, *outFilePtr)
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
@ -122,8 +124,8 @@ func getEntries() *[]string {
|
||||
return &fileList
|
||||
}
|
||||
|
||||
func generateLog(entries []Entry, templateFile string) {
|
||||
file, err := os.Create(outputPath + "log.html")
|
||||
func generateLog(entries []Entry, templateFile string, outFile string) {
|
||||
file, err := os.Create(outputPath + outFile + ".html")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user