Files
fn-serverless/fnctl/build.go
Travis Reeder 3357476583 Updates to fnctl to make UX better (#272)
* See the hello/go README for how this all works now.

* Node support for fnctl auto build

* Updated based on PR comments.
2016-11-14 10:10:29 -08:00

46 lines
866 B
Go

package main
import (
"fmt"
"io"
"os"
"github.com/urfave/cli"
)
func build() cli.Command {
cmd := buildcmd{commoncmd: &commoncmd{}}
flags := append([]cli.Flag{}, cmd.flags()...)
return cli.Command{
Name: "build",
Usage: "build function version",
Flags: flags,
Action: cmd.scan,
}
}
type buildcmd struct {
*commoncmd
}
func (b *buildcmd) scan(c *cli.Context) error {
b.commoncmd.scan(b.walker)
return nil
}
func (b *buildcmd) walker(path string, info os.FileInfo, err error, w io.Writer) error {
walker(path, info, err, w, b.build)
return nil
}
// build will take the found valid function and build it
func (b *buildcmd) build(path string) error {
fmt.Fprintln(b.verbwriter, "building", path)
ff, err := b.buildfunc(path)
if err != nil {
return err
}
fmt.Printf("Function %v built successfully.\n", ff.FullName())
return nil
}