mirror of
https://github.com/bettercap/bettercap
synced 2025-07-11 15:46:59 -07:00
new: new -version command line argument to print version, build information and exit
This commit is contained in:
parent
bf4c841ef9
commit
027f4a3ccc
3 changed files with 16 additions and 2 deletions
|
@ -11,6 +11,7 @@ type Options struct {
|
||||||
Silent *bool
|
Silent *bool
|
||||||
NoColors *bool
|
NoColors *bool
|
||||||
NoHistory *bool
|
NoHistory *bool
|
||||||
|
PrintVersion *bool
|
||||||
EnvFile *string
|
EnvFile *string
|
||||||
Commands *string
|
Commands *string
|
||||||
CpuProfile *string
|
CpuProfile *string
|
||||||
|
@ -24,6 +25,7 @@ func ParseOptions() (Options, error) {
|
||||||
AutoStart: flag.String("autostart", "events.stream, net.recon", "Comma separated list of modules to auto start."),
|
AutoStart: flag.String("autostart", "events.stream, net.recon", "Comma separated list of modules to auto start."),
|
||||||
Caplet: flag.String("caplet", "", "Read commands from this file and execute them in the interactive session."),
|
Caplet: flag.String("caplet", "", "Read commands from this file and execute them in the interactive session."),
|
||||||
Debug: flag.Bool("debug", false, "Print debug messages."),
|
Debug: flag.Bool("debug", false, "Print debug messages."),
|
||||||
|
PrintVersion: flag.Bool("version", false, "Print the version and exit."),
|
||||||
Silent: flag.Bool("silent", false, "Suppress all logs which are not errors."),
|
Silent: flag.Bool("silent", false, "Suppress all logs which are not errors."),
|
||||||
NoColors: flag.Bool("no-colors", false, "Disable output color effects."),
|
NoColors: flag.Bool("no-colors", false, "Disable output color effects."),
|
||||||
NoHistory: flag.Bool("no-history", false, "Disable interactive session history file."),
|
NoHistory: flag.Bool("no-history", false, "Disable interactive session history file."),
|
||||||
|
|
12
main.go
12
main.go
|
@ -6,6 +6,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/bettercap/bettercap/core"
|
"github.com/bettercap/bettercap/core"
|
||||||
"github.com/bettercap/bettercap/log"
|
"github.com/bettercap/bettercap/log"
|
||||||
"github.com/bettercap/bettercap/modules"
|
"github.com/bettercap/bettercap/modules"
|
||||||
|
@ -31,9 +33,15 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
appName := fmt.Sprintf("%s v%s", core.Name, core.Version)
|
if *sess.Options.PrintVersion {
|
||||||
|
fmt.Printf("%s v%s (built for %s %s with %s)\n", core.Name, core.Version, runtime.GOOS, runtime.GOARCH, runtime.Version())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("%s (type '%s' for a list of commands)\n\n", tui.Bold(appName), tui.Bold("help"))
|
appName := fmt.Sprintf("%s v%s", core.Name, core.Version)
|
||||||
|
appBuild := fmt.Sprintf("(built for %s %s with %s)", runtime.GOOS, runtime.GOARCH, runtime.Version())
|
||||||
|
|
||||||
|
fmt.Printf("%s %s [type '%s' for a list of commands]\n\n", tui.Bold(appName), tui.Dim(appBuild), tui.Bold("help"))
|
||||||
|
|
||||||
// Load all modules
|
// Load all modules
|
||||||
modules.LoadModules(sess)
|
modules.LoadModules(sess)
|
||||||
|
|
|
@ -173,6 +173,10 @@ func (s *Session) Module(name string) (err error, mod Module) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) Close() {
|
func (s *Session) Close() {
|
||||||
|
if *s.Options.PrintVersion {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if *s.Options.Debug {
|
if *s.Options.Debug {
|
||||||
fmt.Printf("\nStopping modules and cleaning session state ...\n")
|
fmt.Printf("\nStopping modules and cleaning session state ...\n")
|
||||||
s.Events.Add("session.closing", nil)
|
s.Events.Add("session.closing", nil)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue