Jelajahi Sumber

switch to gonf for configuration

cdelorme 8 tahun lalu
induk
melakukan
895632cdd1
1 mengubah file dengan 10 tambahan dan 14 penghapusan
  1. 10 14
      cmd/staticmd/main.go

+ 10 - 14
cmd/staticmd/main.go

@@ -5,9 +5,7 @@ import (
 	"path/filepath"
 
 	"github.com/cdelorme/go-log"
-	"github.com/cdelorme/go-maps"
-	"github.com/cdelorme/go-option"
-
+	"github.com/cdelorme/gonf"
 	"github.com/cdelorme/staticmd"
 )
 
@@ -27,17 +25,15 @@ func configure() generator {
 		Output: filepath.Join(cwd, "public/"),
 	}
 
-	appOptions := option.App{Description: "command line tool for generating deliverable static content"}
-	appOptions.Flag("template", "path to the template file", "--template", "-t")
-	appOptions.Flag("input", "path to the markdown files", "--input", "-i")
-	appOptions.Flag("output", "path to place generated content", "--output", "-o")
-	appOptions.Flag("book", "combine all content into a single file", "--book", "-b")
-	appOptions.Flag("relative", "use relative paths instead of absolute paths", "--relative", "-r")
-	appOptions.Example("-t template.tmpl -i . -b")
-	appOptions.Example("-t template.tmpl -i src/ -o out/ -r")
-	flags := appOptions.Parse()
-
-	maps.To(smd, flags)
+	g := &gonf.Gonf{Description: "command line tool for generating deliverable static content", Configuration: smd}
+	g.Add("template", "path to the template file", "STATICMD_TEMPLATE", "--template", "-t")
+	g.Add("input", "path to the markdown files", "STATICMD_INPUT", "--input", "-i")
+	g.Add("output", "path to place generated content", "STATICMD_OUTPUT", "--output", "-o")
+	g.Add("book", "combine all content into a single file", "STATICMD_BOOK", "--book", "-b")
+	g.Add("relative", "use relative paths instead of absolute paths", "STATICMD_RELATIVE", "--relative", "-r")
+	g.Example("-t template.tmpl -i . -b")
+	g.Example("-t template.tmpl -i src/ -o out/ -r")
+	g.Load()
 
 	return smd
 }