summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2016-05-14 19:04:39 -0400
committerDave Henderson <dhenderson@gmail.com>2016-05-14 19:04:39 -0400
commitcc70da900865809abd2affdd0bbb426bedbbcfde (patch)
treef1e62f560c3bbd214fe50944ffab8bb2702496b0
parent9989ba3cafb65278a13fa2bc54494a69e5c461eb (diff)
parent4143058f5a4e8b92731b16fb9165eae407e5a2b6 (diff)
Merge pull request #42 from hairyhenderson/switch-to-codegangsta-cli
Switching argument parsing to codegangsta/cli
-rw-r--r--main.go30
1 files changed, 16 insertions, 14 deletions
diff --git a/main.go b/main.go
index 007de5c0..38f1c5f3 100644
--- a/main.go
+++ b/main.go
@@ -1,27 +1,18 @@
package main
import (
- "flag"
- "fmt"
"io"
"io/ioutil"
"log"
"os"
- "github.com/hairyhenderson/gomplate/aws"
- "github.com/hairyhenderson/gomplate/version"
"strings"
"text/template"
-)
-func init() {
- ver := flag.Bool("v", false, "Print version and exit")
- flag.Parse()
- if *ver {
- fmt.Println(version.Version)
- os.Exit(0)
- }
-}
+ "github.com/codegangsta/cli"
+ "github.com/hairyhenderson/gomplate/aws"
+ "github.com/hairyhenderson/gomplate/version"
+)
func (g *Gomplate) createTemplate() *template.Template {
return template.New("template").Funcs(g.funcMap).Option("missingkey=error")
@@ -75,7 +66,18 @@ func NewGomplate() *Gomplate {
}
}
-func main() {
+func runTemplate(c *cli.Context) error {
g := NewGomplate()
g.RunTemplate(os.Stdin, os.Stdout)
+ return nil
+}
+
+func main() {
+ app := cli.NewApp()
+ app.Name = "gomplate"
+ app.Usage = "Process text files with Go templates"
+ app.Version = version.Version
+ app.Action = runTemplate
+
+ app.Run(os.Args)
}