cmd

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

*

  • @Author WANGZILIANG
  • @date 2020/7/7 19:24
  • @Project_name yezihack

*

  • 随机密码
  • @date 2020/7/9 19:13
  • @Project_name yezihack

*

  • @Author sgfoot.com
  • @date 2020/7/7 17:42
  • @Project_name yezihack

*

  • @date 2020/7/9 16:35
  • @Project_name yezihack

*

  • @Author sgfoot
  • @date 2020/7/7 19:38
  • @Project_name yezihack

Index

Constants

This section is empty.

Variables

View Source
var (
	FileSystem = &cobra.Command{
		Use:     "fs",
		Example: "saber fs /data/logs/ --port 7000",
		Short:   "File system",
		Long:    `The file system can browse your directory`,
		Args: func(cmd *cobra.Command, args []string) error {
			if len(args) < 1 {
				return fmt.Errorf("input your directory")
			}
			if !com.IsDir(args[0]) {
				return fmt.Errorf("%s is invalid directory", args[0])
			}
			return nil
		},
		Run: func(cmd *cobra.Command, args []string) {
			err := internal.FileSystem(args[0], port)
			if err != nil {
				fmt.Println("file system err:", err)
				os.Exit(1)
			}
		},
	}
)

command

View Source
var (
	Password = &cobra.Command{
		Use:     "pass",
		Example: "saber pass",
		Short:   "Random Password",
		Long:    `Random generate to password`,
		Args: func(cmd *cobra.Command, args []string) error {
			if len(args) > 0 {
				if _, err := strconv.Atoi(args[0]); err != nil {
					return fmt.Errorf("%s is invalid number", args[0])
				}
			}
			if typeName != "" {
				if !com.IsSliceContainsStr([]string{"num", "char", "num-char", "mix"}, typeName) {
					return fmt.Errorf("password type select:%s", "num, char, num-char, mix. num-char is default")
				}
			}
			return nil
		},
		Run: func(cmd *cobra.Command, args []string) {
			count := 1
			if len(args) > 0 {
				count, _ = strconv.Atoi(args[0])
			}
			result := internal.RandomStrs(length, count, typeName)
			for i := 0; i < len(result); i++ {
				println(result[i])
			}
		},
	}
)
View Source
var (
	TcpProxy = &cobra.Command{
		Use:     "proxy",
		Example: "saber proxy --listen localhost:6379 --remote localhost:7379",
		Short:   "Tcp proxy",
		Long:    "Tcp proxy is traffic forwarding",
		Args: func(cmd *cobra.Command, args []string) error {
			if listenAddr == "" {
				return fmt.Errorf("listen address is nil")
			}
			if remoteAddr == "" {
				return fmt.Errorf("remote address is nil")
			}
			return nil
		},
		Run: func(cmd *cobra.Command, args []string) {
			ctx, cancel := context.WithCancel(context.Background())
			internal.NewTcpProxy(ctx, listenAddr, remoteAddr)
			waitSignal()
			cancel()
			log.Println("tcp proxy is stop")
		},
	}
)

Functions

func Execute

func Execute()

执行

func GetRoot

func GetRoot() *cobra.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

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