ref: 9a2893b7fe2185ba676d395ff5bb22229fed3118
parent: 51eb2ed06f13e1477ebe3ebf7675688c8f8e1246
author: Michael Misch <michaelmisch1985@gmail.com>
date: Wed Nov 27 18:32:35 PST 2019
Start on other runners
--- a/command.go
+++ b/command.go
@@ -34,8 +34,7 @@
return c, nil
}
-func (c command) setEnv() error {
-
+func (c *command) setEnv() error {
dir, err := os.Getwd()
if err != nil {
return err
@@ -49,10 +48,10 @@
return nil
}
-func (c command) setTask(arg string) error {
+func (c *command) setTask(arg string) error {
switch arg {
- //case "help":
- //c.runner = help
+ case "help":
+ c.runner = help
case "init":
c.runner = initFile
case "list":
--- a/runners.go
+++ b/runners.go
@@ -5,15 +5,14 @@
"text/template"
)
-var tmpl = template.Must(template.New("new").Parse("# {{.name}} TODO"))
+var tmpl = template.Must(template.New("new").Parse("# {{.Name}} TODO"))
type makefile struct {
- name string
+ Name string
//nodes []node
}
func initFile(c *command) error {
-
wr, err := os.Create(c.mkfile)
if err != nil {
return err
@@ -20,8 +19,8 @@
}
defer wr.Close()
//TODO(halfwit): Create a more useful type here
- data := &makefile{"test"}
- return tmpl.Execute(wr, data)
+ data := &makefile{c.mkfile}
+ return tmpl.Execute(os.Stdout, data)
}
func list(c *command) error {
@@ -29,22 +28,32 @@
// Pretty print the leaves
return nil
}
+
func listall(c *command) error {
// Parse makefile into DAG
// Pretty print everything
return nil
}
+
func dot(c *command) error {
// Parse makefile into DAG
// Pretty print as dot format
return nil
}
+
func rm(c *command) error {
return nil
}
+
func add(c *command) error {
return nil
}
+
+// generate walks the file looking for a handful of known tokens
func generate(c *command) error {
+ return nil
+}
+
+func help(c *command) error {
return nil
}