Change command arg to move arg for ./rove
This commit is contained in:
parent
1a82c3a6bd
commit
ca00a64112
1 changed files with 20 additions and 6 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
"github.com/mdiluz/rove/pkg/game"
|
||||||
"github.com/mdiluz/rove/pkg/rove"
|
"github.com/mdiluz/rove/pkg/rove"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ func Usage() {
|
||||||
fmt.Println("\tstatus \tprints the server status")
|
fmt.Println("\tstatus \tprints the server status")
|
||||||
fmt.Println("\tregister\tregisters an account and stores it (use with -name)")
|
fmt.Println("\tregister\tregisters an account and stores it (use with -name)")
|
||||||
fmt.Println("\tspawn \tspawns a rover for the current account")
|
fmt.Println("\tspawn \tspawns a rover for the current account")
|
||||||
fmt.Println("\tcommand \tissues commands to the rover")
|
fmt.Println("\tmove \tissues move command to rover")
|
||||||
fmt.Println("\tradar \tgathers radar data for the current rover")
|
fmt.Println("\tradar \tgathers radar data for the current rover")
|
||||||
fmt.Println("\trover \tgets data for current rover")
|
fmt.Println("\trover \tgets data for current rover")
|
||||||
fmt.Println("\nOptions:")
|
fmt.Println("\nOptions:")
|
||||||
|
@ -30,17 +31,23 @@ func Usage() {
|
||||||
var home = os.Getenv("HOME")
|
var home = os.Getenv("HOME")
|
||||||
var filepath = path.Join(home, ".local/share/rove.json")
|
var filepath = path.Join(home, ".local/share/rove.json")
|
||||||
|
|
||||||
|
// General usage
|
||||||
var host = flag.String("host", "", "path to game host server")
|
var host = flag.String("host", "", "path to game host server")
|
||||||
var data = flag.String("data", filepath, "data file for storage")
|
var data = flag.String("data", filepath, "data file for storage")
|
||||||
|
|
||||||
|
// For register command
|
||||||
|
var name = flag.String("name", "", "used with status command for the account name")
|
||||||
|
|
||||||
|
// For the duration command
|
||||||
|
var duration = flag.Int("duration", 1, "used for the move command duration")
|
||||||
|
var bearing = flag.String("bearing", "", "used for the move command bearing (compass direction)")
|
||||||
|
|
||||||
// Config is used to store internal data
|
// Config is used to store internal data
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Host string `json:"host,omitempty"`
|
Host string `json:"host,omitempty"`
|
||||||
Accounts map[string]string `json:"accounts,omitempty"`
|
Accounts map[string]string `json:"accounts,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var name = flag.String("name", "", "used with status command for the account name")
|
|
||||||
|
|
||||||
// verifyId will verify an account ID
|
// verifyId will verify an account ID
|
||||||
func verifyId(id string) error {
|
func verifyId(id string) error {
|
||||||
if len(id) == 0 {
|
if len(id) == 0 {
|
||||||
|
@ -128,9 +135,16 @@ func InnerMain(command string) error {
|
||||||
fmt.Printf("Spawned at position %+v\n", response.Position)
|
fmt.Printf("Spawned at position %+v\n", response.Position)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "command":
|
case "move":
|
||||||
// TODO: Actually assemble requested commands
|
d := rove.CommandData{
|
||||||
d := rove.CommandData{}
|
Commands: []game.Command{
|
||||||
|
{
|
||||||
|
Command: game.CommandMove,
|
||||||
|
Duration: *duration,
|
||||||
|
Bearing: *bearing,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
if err := verifyId(account); err != nil {
|
if err := verifyId(account); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue