mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Rename to GitHub (#3)
* circle * Rename to github and fn->cli * Rename to github and fn->cli
This commit is contained in:
61
cli/build.go
Normal file
61
cli/build.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func build() cli.Command {
|
||||
cmd := buildcmd{}
|
||||
flags := append([]cli.Flag{}, cmd.flags()...)
|
||||
return cli.Command{
|
||||
Name: "build",
|
||||
Usage: "build function version",
|
||||
Flags: flags,
|
||||
Action: cmd.build,
|
||||
}
|
||||
}
|
||||
|
||||
type buildcmd struct {
|
||||
verbose bool
|
||||
noCache bool
|
||||
}
|
||||
|
||||
func (b *buildcmd) flags() []cli.Flag {
|
||||
return []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "v",
|
||||
Usage: "verbose mode",
|
||||
Destination: &b.verbose,
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "no-cache",
|
||||
Usage: "Don't use docker cache",
|
||||
Destination: &b.noCache,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// build will take the found valid function and build it
|
||||
func (b *buildcmd) build(c *cli.Context) error {
|
||||
verbwriter := verbwriter(b.verbose)
|
||||
|
||||
path, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fn, err := findFuncfile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ff, err := buildfunc(verbwriter, fn, b.noCache)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("Function %v built successfully.\n", ff.FullName())
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user