Compare commits
No commits in common. "master" and "v0.0.24" have entirely different histories.
38
argv.go
38
argv.go
|
@ -9,25 +9,18 @@ package main
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var argv args
|
var argv args
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
Gui *EmptyCmd `arg:"subcommand:gui" help:"open the gui"`
|
Verbose bool `arg:"--verbose" help:"talk more"`
|
||||||
Verbose bool `arg:"--verbose" help:"talk more"`
|
Daemon bool `arg:"--daemon" default:"false" help:"run in daemon mode"`
|
||||||
Daemon bool `arg:"--daemon" default:"false" help:"run in daemon mode"`
|
UseME bool `arg:"--me" help:"use /me to connect"`
|
||||||
UseME bool `arg:"--me" help:"use /me to connect"`
|
Port int `arg:"--port" default:"2522" help:"port to run on"`
|
||||||
Port int `arg:"--port" default:"2522" help:"port to run on"`
|
URL string `arg:"--url" help:"url to use"`
|
||||||
URL string `arg:"--url" help:"url to use"`
|
Config string `arg:"--config" help:"config file (default is ~/.config/cloud/gus.text"`
|
||||||
Config string `arg:"--config" help:"config file (default is ~/.config/cloud/gus.text"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type EmptyCmd struct {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (args) Version() string {
|
func (args) Version() string {
|
||||||
|
@ -55,22 +48,3 @@ func init() {
|
||||||
INFO = log.NewFlag("INFO", false, full, short, "general gus")
|
INFO = log.NewFlag("INFO", false, full, short, "general gus")
|
||||||
WARN = log.NewFlag("WARN", true, full, short, "bad things")
|
WARN = log.NewFlag("WARN", true, full, short, "bad things")
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
handles shell autocomplete
|
|
||||||
*/
|
|
||||||
|
|
||||||
func (a args) DoAutoComplete(argv []string) {
|
|
||||||
switch argv[0] {
|
|
||||||
case "playback":
|
|
||||||
fmt.Println("long --uuid purge last submit")
|
|
||||||
case "clean":
|
|
||||||
fmt.Println("")
|
|
||||||
default:
|
|
||||||
if argv[0] == ARGNAME {
|
|
||||||
// list the subcommands here
|
|
||||||
fmt.Println("--json interact playback clean")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
5
doGui.go
5
doGui.go
|
@ -9,6 +9,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -27,6 +28,10 @@ func refresh() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func doGui() {
|
func doGui() {
|
||||||
|
me.myGui = gui.New()
|
||||||
|
me.myGui.InitEmbed(resources)
|
||||||
|
me.myGui.Default()
|
||||||
|
|
||||||
win := gadgets.RawBasicWindow("gus: (squirl your way around networks)")
|
win := gadgets.RawBasicWindow("gus: (squirl your way around networks)")
|
||||||
win.Make()
|
win.Make()
|
||||||
win.Show()
|
win.Show()
|
||||||
|
|
|
@ -5,10 +5,10 @@ package gus;
|
||||||
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
|
||||||
|
|
||||||
enum GusEventType {
|
enum GusEventType {
|
||||||
Connect = 0; // a socket connect attempt
|
Connect = 0; // a socket connect attempt
|
||||||
Disconnect = 1; // a socket closed
|
Disconnect = 1; // a socket closed
|
||||||
Enable = 2; // listening on a port was enabled
|
Enable = 2; // listening on a port was enabled
|
||||||
Disable = 3; // listening on a port was disabled
|
Disable = 3; // listening on a port was disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
message GusSocket {
|
message GusSocket {
|
||||||
|
|
5
exit.go
5
exit.go
|
@ -6,7 +6,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,12 +13,12 @@ func okExit(note string) {
|
||||||
if note != "" {
|
if note != "" {
|
||||||
log.Info("gus exit:", note, "ok")
|
log.Info("gus exit:", note, "ok")
|
||||||
}
|
}
|
||||||
gui.StandardExit()
|
me.myGui.Close()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func badExit(err error) {
|
func badExit(err error) {
|
||||||
log.Info("gus failed: ", err)
|
log.Info("gus failed: ", err)
|
||||||
gui.StandardExit()
|
me.myGui.Close()
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
30
main.go
30
main.go
|
@ -18,7 +18,7 @@ import (
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"go.wit.com/dev/alexflint/arg"
|
"go.wit.com/dev/alexflint/arg"
|
||||||
"go.wit.com/lib/gui/prep"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
@ -26,19 +26,16 @@ import (
|
||||||
var VERSION string
|
var VERSION string
|
||||||
var BUILDTIME string
|
var BUILDTIME string
|
||||||
|
|
||||||
var ARGNAME string = "gus"
|
|
||||||
|
|
||||||
//go:embed resources/*
|
//go:embed resources/*
|
||||||
var resources embed.FS
|
var resources embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
me = new(gusconf)
|
var pp *arg.Parser
|
||||||
prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv)
|
gui.InitArg()
|
||||||
me.myGui = prep.Gui() // prepares the GUI package for go-args
|
pp = arg.MustParse(&argv)
|
||||||
me.pp = arg.MustParse(&argv)
|
|
||||||
|
|
||||||
if me.pp == nil {
|
if pp == nil {
|
||||||
me.pp.WriteHelp(os.Stdout)
|
pp.WriteHelp(os.Stdout)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
log.Info("tmp hack", uuid.New().String())
|
log.Info("tmp hack", uuid.New().String())
|
||||||
|
@ -69,17 +66,16 @@ func main() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
startGus()
|
if gui.NoGui() {
|
||||||
|
startGus()
|
||||||
if argv.Gui != nil {
|
startHTTP()
|
||||||
me.myGui.Start() // loads the GUI toolkit
|
os.Exit(0)
|
||||||
doGui() // start making our forge GUI
|
|
||||||
}
|
}
|
||||||
|
|
||||||
startHTTP()
|
startGus()
|
||||||
os.Exit(0)
|
|
||||||
// debug() // sits here forever
|
|
||||||
// go NewWatchdog()
|
// go NewWatchdog()
|
||||||
|
go startHTTP()
|
||||||
|
doGui()
|
||||||
}
|
}
|
||||||
|
|
||||||
func startGus() {
|
func startGus() {
|
||||||
|
|
|
@ -7,18 +7,15 @@ import (
|
||||||
sync "sync"
|
sync "sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/prep"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var me *gusconf
|
var me *gusconf
|
||||||
|
|
||||||
// this app's variables
|
// this app's variables
|
||||||
type gusconf struct {
|
type gusconf struct {
|
||||||
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
myGui *gui.Node // the base of the gui
|
||||||
myGui *prep.GuiPrep // the base of the gui
|
|
||||||
portmaps *Portmaps // the portmap window
|
portmaps *Portmaps // the portmap window
|
||||||
portwin *stdTableWin // the portwin window
|
portwin *stdTableWin // the portwin window
|
||||||
events *Events // the event log
|
events *Events // the event log
|
||||||
|
|
Loading…
Reference in New Issue