Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NewCmd = &cobra.Command{
Use: "new",
Example: "hasaki new demo-api",
Short: "create a new project.",
Long: `create a new project with hasaki layout.`,
Run: run,
}
View Source
var UpgradeCmd = &cobra.Command{ Use: "upgrade", Short: "Upgrade the hasaki command.", Long: "Upgrade the hasaki command.", Example: "hasaki upgrade", Run: func(_ *cobra.Command, _ []string) { fmt.Printf("go install %s\n", config.HasakiCmd) cmd := exec.Command("go", "install", config.HasakiCmd) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { log.Fatalf("go install %s error\n", err) } fmt.Printf("\n🎉 Hasaki upgrade successfully!\n\n") }, }
View Source
var WireCmd = &cobra.Command{ Use: "wire", Short: "hasaki wire [wire.go path]", Long: "hasaki wire [wire.go path]", Example: "hasaki wire cmd/server", Run: func(cmd *cobra.Command, args []string) { cmdArgs, _ := helper.SplitArgs(cmd, args) var dir string if len(cmdArgs) > 0 { dir = cmdArgs[0] } base, err := os.Getwd() if err != nil { fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err) return } if dir == "" { wirePath, err := findWire(base) if err != nil { fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err) return } switch len(wirePath) { case 0: fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", "The cmd directory cannot be found in the current directory") return case 1: for _, v := range wirePath { dir = v } default: var wirePaths []string for k := range wirePath { wirePaths = append(wirePaths, k) } prompt := &survey.Select{ Message: "Which directory do you want to run?", Options: wirePaths, PageSize: 10, } e := survey.AskOne(prompt, &dir) if e != nil || dir == "" { return } dir = wirePath[dir] } } wire(dir) }, }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.