breach/breacher/commands.go

53 lines
959 B
Go

package breacher
import (
"fmt"
"io"
"log"
"os"
"github.com/spf13/cobra"
)
var Cmd = &cobra.Command{
Use: "breacher",
Short: "Breacher is a tool to breach network protections",
Long: "",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if rsilent {
log.SetOutput(io.Discard)
}
// log.SetFlags(0)
},
}
var rsilent bool
func init() {
Cmd.PersistentFlags().BoolVarP(&rsilent, "silent", "s", false, "silent log output")
Cmd.AddCommand(versionCmd)
Cmd.AddCommand(forwardCmd)
Cmd.AddCommand(proxyCmd)
Cmd.AddCommand(sshCmd)
Cmd.SetVersionTemplate(`{{.Version}}{{"\n"}}`)
}
func Execute() {
if err := Cmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
var (
Version string
Build string
)
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of breacher",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("breacher version %s - %s\n", Version, Build)
},
}