aboutsummaryrefslogtreecommitdiff
path: root/diplomacy/server/run.py
diff options
context:
space:
mode:
authorPhilip Paquette <pcpaquette@gmail.com>2019-09-11 12:58:45 -0400
committerPhilip Paquette <pcpaquette@gmail.com>2019-09-14 18:18:53 -0400
commitabb42dcd4886705d6ba8af27f68ef605218ac67c (patch)
tree9ae16f7a09fff539fa72e65198e284bca6ac3376 /diplomacy/server/run.py
parenta954a00d263750c279dbb2c0a9ae85707022bcd7 (diff)
Added ReadtheDocs documentation for the public API
- Reformatted the docstring to be compatible - Added tests to make sure the documentation compiles properly - Added sphinx as a pip requirement Co-authored-by: Philip Paquette <pcpaquette@gmail.com> Co-authored-by: notoraptor <stevenbocco@gmail.com>
Diffstat (limited to 'diplomacy/server/run.py')
-rwxr-xr-xdiplomacy/server/run.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/diplomacy/server/run.py b/diplomacy/server/run.py
index f47ed4f..8f28e3d 100755
--- a/diplomacy/server/run.py
+++ b/diplomacy/server/run.py
@@ -16,20 +16,29 @@
# with this program. If not, see <https://www.gnu.org/licenses/>.
# ==============================================================================
""" Small module script to quickly start a server with pretty log-printing.
+
You can stop the server with keyboard interruption (Ctrl+C). Usage:
- python -m diplomacy.server.run # run on port 8432.
- python -m diplomacy.server.run --port=<given port> # run on given port.
+
+ .. code-block:: bash
+
+ # run on port 8432.
+ python -m diplomacy.server.run
+
+ # run on given port.
+ python -m diplomacy.server.run --port=<given port>
+
"""
import argparse
from diplomacy import Server
from diplomacy.utils import constants
-PARSER = argparse.ArgumentParser(description='Run server.')
-PARSER.add_argument('--port', '-p', type=int, default=constants.DEFAULT_PORT,
- help='run on the given port (default: %s)' % constants.DEFAULT_PORT)
-ARGS = PARSER.parse_args()
+if __name__ == '__main__':
+ PARSER = argparse.ArgumentParser(description='Run server.')
+ PARSER.add_argument('--port', '-p', type=int, default=constants.DEFAULT_PORT,
+ help='run on the given port (default: %s)' % constants.DEFAULT_PORT)
+ ARGS = PARSER.parse_args()
-try:
- Server().start(port=ARGS.port)
-except KeyboardInterrupt:
- print('Keyboard interruption.')
+ try:
+ Server().start(port=ARGS.port)
+ except KeyboardInterrupt:
+ print('Keyboard interruption.')