Begin implementing interactive mode
This commit is contained in:
parent
24afa08970
commit
5474966220
42
main.go
42
main.go
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -13,26 +14,41 @@ import (
|
|||||||
|
|
||||||
var settings = make(map[string]string)
|
var settings = make(map[string]string)
|
||||||
|
|
||||||
func argParse() {
|
func main() {
|
||||||
inputModePtr := flag.String("inputMode", "cmd", "Where to read mailq output from. Available options: \"stdin\", \"cmd\"")
|
parseArguments()
|
||||||
mailqCommandPtr := flag.String("mailqCommand", "mailq", "Command to use for getting mailq output")
|
if settings["interactive"] == "false" {
|
||||||
mailqCommandArgsPtr := flag.String("mailqCommandArgs", "", "Optional arguments to pass to mailqCommand")
|
showQueue()
|
||||||
flag.Parse()
|
}
|
||||||
settings["inputMode"] = *inputModePtr
|
if settings["interactive"] == "true" {
|
||||||
settings["mailqCommand"] = *mailqCommandPtr
|
interactiveShell()
|
||||||
settings["mailqCommandArgs"] = *mailqCommandArgsPtr
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func parseArguments() {
|
||||||
argParse()
|
inputPtr := flag.String("input", "cmd", "Where to read mailq output from. Available options: \"stdin\", \"cmd\"")
|
||||||
|
mailqCommandPtr := flag.String("mailqCommand", "mailq", "Command to use for getting mailq output")
|
||||||
|
mailqCommandArgsPtr := flag.String("mailqCommandArgs", "", "Optional arguments to pass to mailqCommand")
|
||||||
|
interactivePtr := flag.Bool("interactive", false, "Set to true for shell mode")
|
||||||
|
flag.Parse()
|
||||||
|
settings["input"] = *inputPtr
|
||||||
|
settings["mailqCommand"] = *mailqCommandPtr
|
||||||
|
settings["mailqCommandArgs"] = *mailqCommandArgsPtr
|
||||||
|
settings["interactive"] = strconv.FormatBool(*interactivePtr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func interactiveShell() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func showQueue() {
|
||||||
var entries []parser.QEntry
|
var entries []parser.QEntry
|
||||||
var err error
|
var err error
|
||||||
if settings["inputMode"] == "stdin" {
|
if settings["input"] == "stdin" {
|
||||||
entries, err = readFromStdin()
|
entries, err = readFromStdin()
|
||||||
} else if settings["inputMode"] == "cmd" {
|
} else if settings["input"] == "cmd" {
|
||||||
entries, err = readFromCmd(exec.Command(settings["mailqCommand"]))
|
entries, err = readFromCmd(exec.Command(settings["mailqCommand"]))
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Unsupported inputMode!")
|
fmt.Printf("Unsupported input!")
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user