From 4e3c97862ede80e8a29f4e9432674e8ac51d5d56 Mon Sep 17 00:00:00 2001 From: sxv20_ Date: Tue, 16 Apr 2019 17:22:44 +0100 Subject: [PATCH] Update docs Former-commit-id: 381a759ebcefb4f0fad76fe66ca2720b572849b5 --- server/src/cmd.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/server/src/cmd.rs b/server/src/cmd.rs index 73d0cc1362..b090f38fc0 100644 --- a/server/src/cmd.rs +++ b/server/src/cmd.rs @@ -1,6 +1,6 @@ -//! #Implementing new commands +//! # Implementing new commands //! To implement a new command, add an instance of `ChatCommand` to `CHAT_COMMANDS` -//! and provide a handler function +//! and provide a handler function. use crate::Server; use common::{comp, msg::ServerMsg}; @@ -12,13 +12,19 @@ use lazy_static::lazy_static; /// Struct representing a command that a user can run from server chat pub struct ChatCommand { - /// The keyword used to invoke the function, omitting the leading '/' + /// The keyword used to invoke the command, omitting the leading '/' pub keyword: &'static str, - /// the format string used by `scan_fmt` to parse arguments + /// A format string for parsing arguments arg_fmt: &'static str, /// message to explain how the command is used help_string: &'static str, - /// handler function called when the command is executed + /// Handler function called when the command is executed + /// # Arguments + /// * `&mut Server` - the `Server` instance executing the command + /// * `EcsEntity` - an `Entity` corresponding to the player that invoked the command + /// * `String` - a `String` containing the part of the command after the keyword + /// * `&ChatCommand` - the command to execute with the above arguments + /// Handler functions must parse arguments from the the given `String` (`scan_fmt!` is included for this purpose) handler: fn(&mut Server, EcsEntity, String, &ChatCommand), }