64 lines
2.2 KiB
Go
64 lines
2.2 KiB
Go
package main
|
|
|
|
import "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"`
|
|
Config string `arg:"env:VIRTIGO_HOME" help:"defaults to ~/.config/virtigo/"`
|
|
Server string `arg:"env:VIRTIGO_SERVER" help:"what virtigo cluster to connect to"`
|
|
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"`
|
|
}
|
|
|
|
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.
|
|
`
|
|
}
|
|
|
|
func (args) Version() string {
|
|
return ARGNAME + " " + VERSION + " Built on " + BUILDTIME
|
|
}
|
|
|
|
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")
|
|
}
|