in cmd/build-fc-zip/main.go [18:53]
func main() {
app := &cli.App{
Name: "build-fc-zip",
Usage: "Put an executable and supplemental files into a zip file that works with Aliyun FunctionCompute.",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Value: "",
Usage: "output file path for the zip. Defaults to the first input file name.",
},
},
Action: func(c *cli.Context) error {
if !c.Args().Present() {
return errors.New("no input provided")
}
inputExe := c.Args().First()
outputZip := c.String("output")
if outputZip == "" {
outputZip = fmt.Sprintf("%s.zip", filepath.Base(inputExe))
}
if err := compressExeAndArgs(outputZip, inputExe, c.Args().Tail()); err != nil {
return fmt.Errorf("failed to compress file: %v", err)
}
log.Print("wrote " + outputZip)
return nil
},
}
if err := app.Run(os.Args); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}