package main import ( "github.com/spf13/cobra" ) var httpPort, httpIP, httpPath, httpBasicAuth, httpCertKey, logPath string var doUpload, daemon bool func init() { httpcmd.Flags().StringVarP(&httpPort, "port", "p", "80", "监听端口") httpcmd.Flags().StringVarP(&httpIP, "ip", "i", "0.0.0.0", "监听ip") httpcmd.Flags().StringVarP(&httpPath, "folder", "f", "./", "本地文件地址") httpcmd.Flags().BoolVarP(&doUpload, "upload", "u", false, "是否开启文件上传") httpcmd.Flags().BoolVarP(&doUpload, "daemon", "d", false, "以后台进程运行") httpcmd.Flags().StringVarP(&httpBasicAuth, "auth", "a", "", "HTTP BASIC AUTH认证(用户名:密码)") httpcmd.Flags().StringVarP(&httpBasicAuth, "log", "l", "", "log地址") httpcmd.Flags().StringVarP(&httpCertKey, "cert", "c", "", "TLS证书路径,用:分割证书与密钥") httpcmd.Flags().MarkHidden("front") } // httpCmd represents the http command var httpcmd = &cobra.Command{ Use: "http", Short: "HTTP文件服务器", Long: `HTTP文件服务器`, Run: func(cmd *cobra.Command, args []string) { if daemon { } }, }