git commit -m "first commit"
This commit is contained in:
28
cmd/nmap.go
Normal file
28
cmd/nmap.go
Normal file
@ -0,0 +1,28 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"git.treesir.pub/DevOps/devops-sing/nmap/scan"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
getIP int
|
||||
cidr string
|
||||
)
|
||||
|
||||
var nmapCmd = &cobra.Command{
|
||||
Use: "nmap",
|
||||
Short: "use nmap scan cidr",
|
||||
Long: `use nmap scan cidr`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
scan.Pcidr(cidr, getIP)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
nmapCmd.Flags().IntVarP(&getIP, "getIP", "g", 1, "get ip address")
|
||||
nmapCmd.Flags().StringVarP(&cidr, "cidr", "c", "192.168.8.0/24", "cidr address")
|
||||
nmapCmd.MarkFlagRequired("getIP")
|
||||
nmapCmd.MarkFlagRequired("cidr")
|
||||
|
||||
}
|
30
cmd/root.go
Normal file
30
cmd/root.go
Normal file
@ -0,0 +1,30 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "devops-sing",
|
||||
Short: "Devops-sing is a tool for devops",
|
||||
Long: `Devops-sing is a tool for devops.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Execute the command devops-sing -h to view the usage method.")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand()
|
||||
rootCmd.AddCommand(nmapCmd)
|
||||
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user