Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &cli.Command{ Name: "init", Aliases: nil, Usage: "fns init --mod={mod} --img={docker image name} --work={true} {project dir}", Description: "init fns project", ArgsUsage: "", Category: "", Flags: []cli.Flag{ &cli.StringFlag{ Name: "mod", Aliases: []string{"m"}, Required: true, Usage: "project go mod path", }, &cli.BoolFlag{ Name: "work", Aliases: []string{"w"}, Required: false, Usage: "use go work", }, &cli.StringFlag{ Name: "img", Aliases: []string{"i"}, Required: false, Usage: "project docker image name", }, }, Action: func(ctx *cli.Context) (err error) { projectDir := strings.TrimSpace(ctx.Args().First()) if projectDir == "" { projectDir = "." } if !filepath.IsAbs(projectDir) { projectDir, err = filepath.Abs(projectDir) if err != nil { err = errors.Warning("fns: init fns project failed").WithCause(err).WithMeta("dir", projectDir) return } } projectDir = filepath.ToSlash(projectDir) projectPath := strings.TrimSpace(ctx.String("mod")) img := strings.TrimSpace(ctx.String("img")) work := ctx.Bool("work") writeErr := base.Write(ctx.Context, projectPath, img, work, projectDir) if writeErr != nil { err = errors.Warning("fns: init fns project failed").WithCause(writeErr).WithMeta("dir", projectDir).WithMeta("path", projectPath) return } if work { fmt.Println("fns: project has been initialized, please run `go work sync` and `go mod tidy` to fetch requires and run `go generate` to generate source files!") } else { fmt.Println("fns: project has been initialized, please run `go mod tidy` to fetch requires and run `go generate` to generate source files!") } return }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.