From 8d764e147766fca3d7cb42c014749f4d441dfde0 Mon Sep 17 00:00:00 2001 From: bvanvugt <1531419+bvanvugt@users.noreply.github.com> Date: Thu, 10 Dec 2020 15:02:29 -0800 Subject: [PATCH] Update build path and docs. --- .gitignore | 3 --- cli/README.md | 41 ++++++++++++++++++++--------------- cli/battlesnake/main.go | 7 ++++++ cli/{cmd => commands}/play.go | 9 ++++---- cli/{cmd => commands}/root.go | 2 +- cli/main.go | 7 ------ 6 files changed, 36 insertions(+), 33 deletions(-) create mode 100644 cli/battlesnake/main.go rename cli/{cmd => commands}/play.go (98%) rename cli/{cmd => commands}/root.go (98%) delete mode 100644 cli/main.go diff --git a/.gitignore b/.gitignore index 647a1f7..2ca1b78 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,3 @@ # General .DS_Store - -# Executable -battlesnake diff --git a/cli/README.md b/cli/README.md index 1232893..444f21f 100644 --- a/cli/README.md +++ b/cli/README.md @@ -1,15 +1,18 @@ # Battlesnake CLI -This tool allows running a Battlesnake game locally. There are several command- -line options for the play verb, including the ability to send snakes requests -sequentially or all at the same time, and also to set a timeout limit. +This tool allows running a Battlesnake game locally. There are several command-line options for running games, including the ability to send Battlesnake requests sequentially or concurrently, set a custom timeout, etc. + +## Installation + +The Battlesnake CLI requires Go 1.13 or later. + +``` +go get github.com/BattlesnakeOfficial/rules/cli/battlesnake +``` ## Usage ``` -Use the CLI to configure and play a game of Battlesnake against -multiple snakes, with multiple rulesets. - Usage: battlesnake play [flags] @@ -29,19 +32,23 @@ Global Flags: --config string config file (default is $HOME/.battlesnake.yaml) ``` -Names and URLs will be paired together in sequence, so in the following example -it effectively makes: - -* Snake1: http://snake1-url-whatever:port -* Snake2: http://snake2-url-whatever:port - -Names are optional, but definitely way easier to read than UUIDs. URLs are -optional too, but your snake will lose if the server is only sending move -requests to http://example.com. - +Battlesnake names and URLs will be paired together in sequence, for example: ``` -battlesnake play --width 7 --height 7 --name Snake1 --url http://snake1-url-whatever:port --name Snake2 --url http://snake2-url-whatever:port +battlesnake play --name Snake1 --url http://snake1-url-whatever --name Snake2 --url http://snake2-url-whatever +``` + +This will create a game with the following Battlesnakes: +* Snake1, http://snake1-url-whatever +* Snake2, http://snake2-url-whatever + +Names are optional, and if you don't provide them UUIDs will be generated instead. However names are way easier to read and highly recommended! + +URLs are technically optional too, but your Battlesnake will lose if the server is only sending move requests to http://example.com. + +Example creating a 7x7 Standard game with two Battlesnakes: +``` +battlesnake play --width 7 --height 7 --name Snake1 --url http://snake1-url-whatever --name Snake2 --url http://snake2-url-whatever ``` ### Sample Output diff --git a/cli/battlesnake/main.go b/cli/battlesnake/main.go new file mode 100644 index 0000000..a368d23 --- /dev/null +++ b/cli/battlesnake/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/BattlesnakeOfficial/rules/cli/commands" + +func main() { + commands.Execute() +} diff --git a/cli/cmd/play.go b/cli/commands/play.go similarity index 98% rename from cli/cmd/play.go rename to cli/commands/play.go index cf87d2f..c1b51ec 100644 --- a/cli/cmd/play.go +++ b/cli/commands/play.go @@ -1,4 +1,4 @@ -package cmd +package commands import ( "bytes" @@ -93,10 +93,9 @@ var ViewMap bool var playCmd = &cobra.Command{ Use: "play", - Short: "Play a game of Battlesnake", - Long: `Use the CLI to configure and play a game of Battlesnake against -multiple snakes, with multiple rulesets.`, - Run: run, + Short: "Play a game of Battlesnake locally.", + Long: "Play a game of Battlesnake locally.", + Run: run, } func init() { diff --git a/cli/cmd/root.go b/cli/commands/root.go similarity index 98% rename from cli/cmd/root.go rename to cli/commands/root.go index c990015..c8dc846 100644 --- a/cli/cmd/root.go +++ b/cli/commands/root.go @@ -1,4 +1,4 @@ -package cmd +package commands import ( "fmt" diff --git a/cli/main.go b/cli/main.go deleted file mode 100644 index 868b870..0000000 --- a/cli/main.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "github.com/BattlesnakeOfficial/rules/cli/cmd" - -func main() { - cmd.Execute() -}