mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: improve UX and publish/deploy command (#359)
* fn: improve UX and publish/deploy command * fn: remove wrong use cases for deploy * fn: fix regression introduced by merge
This commit is contained in:
38
fn/build.go
38
fn/build.go
@@ -8,35 +8,45 @@ import (
|
||||
)
|
||||
|
||||
func build() cli.Command {
|
||||
cmd := buildcmd{commoncmd: &commoncmd{}}
|
||||
cmd := buildcmd{}
|
||||
flags := append([]cli.Flag{}, cmd.flags()...)
|
||||
return cli.Command{
|
||||
Name: "build",
|
||||
Usage: "build function version",
|
||||
Flags: flags,
|
||||
Action: cmd.scan,
|
||||
Action: cmd.build,
|
||||
}
|
||||
}
|
||||
|
||||
type buildcmd struct {
|
||||
*commoncmd
|
||||
verbose bool
|
||||
}
|
||||
|
||||
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) error {
|
||||
walker(path, info, err, b.build)
|
||||
return nil
|
||||
func (b *buildcmd) flags() []cli.Flag {
|
||||
return []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "v",
|
||||
Usage: "verbose mode",
|
||||
Destination: &b.verbose,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// build will take the found valid function and build it
|
||||
func (b *buildcmd) build(path string) error {
|
||||
fmt.Fprintln(b.verbwriter, "building", path)
|
||||
func (b *buildcmd) build(c *cli.Context) error {
|
||||
verbwriter := verbwriter(b.verbose)
|
||||
|
||||
ff, err := b.buildfunc(path)
|
||||
path, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fn, err := findFuncfile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintln(verbwriter, "building", fn)
|
||||
ff, err := buildfunc(verbwriter, fn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user