wire

package
v0.0.0-...-c62d208 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdWire = &cobra.Command{
	Use:     "wire",
	Short:   "nunu wire [wire.go path]",
	Long:    "nunu wire [wire.go path]",
	Example: "nunu 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 wire.go 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)

	},
}
View Source
var CmdWireAll = &cobra.Command{
	Use:     "all",
	Short:   "nunu wire all",
	Long:    "nunu wire all",
	Example: "nunu wire all",
	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 wire.go cannot be found in the current directory")
				return
			default:
				for _, v := range wirePath {
					wire(v)
				}
			}
		}

	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL