Files
fn-serverless/fnctl/build.go
Pedro Nasser 4c31c29fb8 new commands fnctl build and bump (#204)
New commands & refectoring

* fnctl: refactor code to improve reuse between commands

build, bump and publish (formerly update) share a lot of code,
this refactor ensure their logic are correctly reused. It renames
update to publish, so it would be a strong diff between "update"
and build.

* fnctl: remove unnecessary dependency for build and bump

* fnctl: improve code reuse between bump, build and publish

Unify the use of walker function in all these three commands and
drop dry-run support.

* Code grooming

- errcheck

* fnctl: update README.md to be in sync with actual execution output

* fnctl: move scan function to commoncmd structure

* fnctl: change verbose flag handling does not use global variable anymore
2016-11-01 00:11:29 -02:00

42 lines
768 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)
_, err := b.buildfunc(path)
return err
}