@@ -2,14 +2,16 @@ package cmd
22
33import (
44 "errors"
5+ "os"
6+ "runtime"
7+
58 cc "github.com/ivanpirog/coloredcobra"
69 "github.com/shadowabi/Serverless_PortScan_rebuild/config"
710 "github.com/shadowabi/Serverless_PortScan_rebuild/define"
811 "github.com/shadowabi/Serverless_PortScan_rebuild/pkg"
912 "github.com/shadowabi/Serverless_PortScan_rebuild/utils/Error"
1013 "github.com/shadowabi/Serverless_PortScan_rebuild/utils/log"
1114 "github.com/spf13/cobra"
12- "os"
1315)
1416
1517var RootCmd = & cobra.Command {
@@ -29,6 +31,8 @@ Serverless_PortScan is used to scan ports using cloud functions.
2931` ,
3032 PersistentPostRun : func (cmd * cobra.Command , args []string ) {
3133 log .Init (logLevel )
34+ },
35+ Run : func (cmd * cobra.Command , args []string ) {
3236 if define .Url != "" && define .File != "" {
3337 Error .HandleFatal (errors .New ("参数不可以同时存在" ))
3438 return
@@ -37,9 +41,6 @@ Serverless_PortScan is used to scan ports using cloud functions.
3741 Error .HandleFatal (errors .New ("必选参数为空,请输入 -u 参数或 -f 参数" ))
3842 return
3943 }
40- },
41- Run : func (cmd * cobra.Command , args []string ) {
42- cmd .Println (cmd .Long ) // print title
4344
4445 if define .Port == "" {
4546 define .Port = config .C .PortList
@@ -76,14 +77,16 @@ func init() {
7677}
7778
7879func Execute () {
79- cc .Init (& cc.Config {
80- RootCmd : RootCmd ,
81- Headings : cc .HiGreen + cc .Underline ,
82- Commands : cc .Cyan + cc .Bold ,
83- Example : cc .Italic ,
84- ExecName : cc .Bold ,
85- Flags : cc .Cyan + cc .Bold ,
86- })
80+ if runtime .GOOS != "windows" {
81+ cc .Init (& cc.Config {
82+ RootCmd : RootCmd ,
83+ Headings : cc .HiGreen + cc .Underline ,
84+ Commands : cc .Cyan + cc .Bold ,
85+ Example : cc .Italic ,
86+ ExecName : cc .Bold ,
87+ Flags : cc .Cyan + cc .Bold ,
88+ })
89+ }
8790 err := RootCmd .Execute ()
8891 if err != nil {
8992 os .Exit (1 )
0 commit comments