summaryrefslogtreecommitdiff
path: root/argv.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-19 05:44:42 -0500
committerJeff Carr <[email protected]>2025-10-19 05:44:42 -0500
commitf730ed88ee48128da1d4f841fd43616621613f00 (patch)
treea511cbe46e3a6ca13c240fc15a03baf90165f09a /argv.go
parent34015f3d4ee487efe329d0387458f609343c2f9f (diff)
new argv that somewhat works betterv0.2.87
Diffstat (limited to 'argv.go')
-rw-r--r--argv.go109
1 files changed, 0 insertions, 109 deletions
diff --git a/argv.go b/argv.go
deleted file mode 100644
index aba76e7..0000000
--- a/argv.go
+++ /dev/null
@@ -1,109 +0,0 @@
-package main
-
-import (
- "os"
-
- "go.wit.com/lib/protobuf/argvpb"
- "go.wit.com/log"
-)
-
-/*
- this parses the command line arguements
-
- this enables command line options from other packages like 'gui' and 'log'
-*/
-
-var argv args
-
-type args struct {
- List *ListCmd `arg:"subcommand:list" help:"list things"`
- Droplet *DropletCmd `arg:"subcommand:droplet" help:"send events to a droplet"`
- Config string `arg:"env:VIRTIGO_HOME" help:"defaults to ~/.config/virtigo/"`
- Server string `arg:"env:VIRTIGO_SERVER" help:"what virtigo cluster to connect to"`
- Localhost bool `arg:"--localhost" help:"use the local libvirt"`
- Daemon bool `arg:"--daemon" help:"run as a daemon"`
- Verbose bool `arg:"--verbose" help:"talk more"`
- Port int `arg:"--port" default:"8080" help:"allow droplet events via http"`
- Xml []string `arg:"--libvirt" help:"import qemu xml files: --libvirt /etc/libvirt/qemu/*.xml"`
- Admin bool `arg:"--admin" help:"enter admin mode"`
- Bash bool `arg:"--bash" help:"generate bash completion"`
- BashAuto []string `arg:"--auto-complete" help:"todo: move this to go-arg"`
-}
-
-type EmptyCmd struct {
-}
-
-type testCmd string
-
-type ListCmd struct {
- Droplets *EmptyCmd `arg:"subcommand:droplets" help:"list droplets"`
- Hypervisors *EmptyCmd `arg:"subcommand:hypervisors" help:"list hypervisors"`
- On bool `arg:"--on" help:"only show things that are on"`
-}
-
-type DropletCmd struct {
- Start *EmptyCmd `arg:"subcommand:start" help:"start droplet"`
- Stop *EmptyCmd `arg:"subcommand:stop" help:"stop droplet"`
- Show *EmptyCmd `arg:"subcommand:show" help:"show droplet"`
- Console *EmptyCmd `arg:"subcommand:console" help:"open serial console"`
- VNC *EmptyCmd `arg:"subcommand:vnc" help:"open VNC console"`
- Spice *EmptyCmd `arg:"subcommand:spice" help:"open spiceconsole"`
- Name string `arg:"--name" help:"what droplet to start"`
-}
-
-func (a args) Description() string {
- return `
- virtigo: control your cluster
-
-This maintains a master list of all your vm's (aka 'droplets')
-in your homelab cloud. You can import libvirt xml files.
-This app talks to your hypervisors via the virtigod daemon.
-`
-}
-
-var INFO *log.LogFlag
-var POLL *log.LogFlag
-var WARN *log.LogFlag
-var EVENT *log.LogFlag
-
-func init() {
- full := "go.wit.com/apps/virtigo"
- short := "virtigo"
-
- INFO = log.NewFlag("INFO", false, full, short, "general virtigo")
- POLL = log.NewFlag("POLL", false, full, short, "virtigo polling")
- WARN = log.NewFlag("WARN", true, full, short, "bad things")
- EVENT = log.NewFlag("EVENT", true, full, short, "hypeprvisor/droplet events")
-}
-
-/*
- handles shell autocomplete
-*/
-
-func (args) Version() string {
- return argvpb.StandardVersion(ARGNAME, VERSION, BUILDTIME)
-}
-
-func (args) Appname() string {
- return ARGNAME
-}
-
-func (args) Buildtime() (string, string) {
- return BUILDTIME, VERSION
-}
-
-func (args) ArgvGui() error {
- me.myGui = argvpb.Gui() // adds the GUI package argv support
- return nil
-}
-
-// sends the strings to bash or zsh that will be your options
-func (a args) SendCompletionStrings(pb *argvpb.Argv) {
- if pb.Cmd == "" {
- base := []string{"--version", "list", "droplet"}
- pb.SendStrings(base)
- } else {
- pb.SubCommand(pb.Goargs...)
- }
- os.Exit(0)
-}