2013-09-04 22:02:17 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2013 Aaron Lindsay <aaron@aclindsay.com>
|
|
|
|
*/
|
|
|
|
|
2013-02-10 23:39:23 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2013-09-04 21:29:53 -04:00
|
|
|
"asink"
|
2013-02-11 23:17:12 -05:00
|
|
|
"fmt"
|
2013-02-18 20:44:00 -05:00
|
|
|
"os"
|
2013-02-10 23:39:23 -05:00
|
|
|
)
|
|
|
|
|
2013-09-03 23:33:36 -04:00
|
|
|
type Command struct {
|
|
|
|
cmd string
|
|
|
|
fn func(args []string)
|
|
|
|
explanation string
|
2013-02-18 20:44:00 -05:00
|
|
|
}
|
|
|
|
|
2013-09-03 23:33:36 -04:00
|
|
|
var commands []Command = []Command{
|
|
|
|
Command{
|
|
|
|
cmd: "start",
|
|
|
|
fn: StartClient,
|
|
|
|
explanation: "Start the client daemon",
|
|
|
|
},
|
|
|
|
Command{
|
|
|
|
cmd: "stop",
|
|
|
|
fn: StopClient,
|
|
|
|
explanation: "Stop the client daemon",
|
|
|
|
},
|
2013-09-04 23:09:28 -04:00
|
|
|
Command{
|
|
|
|
cmd: "status",
|
|
|
|
fn: GetStatus,
|
|
|
|
explanation: "Get a summary of the client's status",
|
|
|
|
},
|
2013-09-04 21:29:53 -04:00
|
|
|
Command{
|
|
|
|
cmd: "version",
|
|
|
|
fn: PrintVersion,
|
|
|
|
explanation: "Display the current version",
|
|
|
|
},
|
2013-02-10 23:39:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2013-09-03 23:33:36 -04:00
|
|
|
if len(os.Args) > 1 {
|
|
|
|
cmd := os.Args[1]
|
|
|
|
for _, c := range commands {
|
|
|
|
if c.cmd == cmd {
|
|
|
|
c.fn(os.Args[2:])
|
2013-08-14 07:26:52 -04:00
|
|
|
return
|
|
|
|
}
|
2013-08-13 23:18:17 -04:00
|
|
|
}
|
2013-09-03 23:33:36 -04:00
|
|
|
fmt.Println("Invalid subcommand specified, please pick from the following:")
|
2013-08-13 21:55:17 -04:00
|
|
|
} else {
|
2013-09-03 23:33:36 -04:00
|
|
|
fmt.Println("No subcommand specified, please pick one from the following:")
|
2013-04-01 23:59:40 -04:00
|
|
|
}
|
2013-09-03 23:33:36 -04:00
|
|
|
for _, c := range commands {
|
|
|
|
fmt.Printf("\t%s\t\t%s\n", c.cmd, c.explanation)
|
2013-02-20 23:43:01 -05:00
|
|
|
}
|
2013-02-10 23:39:23 -05:00
|
|
|
}
|
2013-09-04 21:29:53 -04:00
|
|
|
|
|
|
|
func PrintVersion(args []string) {
|
|
|
|
fmt.Println("Asink client version " + asink.VERSION_STRING + ", using version " + asink.API_VERSION_STRING + " of the Asink API.")
|
|
|
|
}
|