diff --git a/CHANGELOG.md b/CHANGELOG.md index f2f86a7256..4e8e8612d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added day duration slider configuration on map creation UI. - Potion of Agility - A way for servers to specify must-accept rules for players +- A flag argument type for commands ### Changed diff --git a/common/src/cmd.rs b/common/src/cmd.rs index dc1f318757..fa18862587 100644 --- a/common/src/cmd.rs +++ b/common/src/cmd.rs @@ -604,7 +604,9 @@ impl ServerChatCommand { Some(Moderator), ), ServerChatCommand::Kill => cmd(vec![], "Kill yourself", None), - ServerChatCommand::KillNpcs => cmd(vec![], "Kill the NPCs", Some(Admin)), + ServerChatCommand::KillNpcs => { + cmd(vec![Flag("--also-pets")], "Kill the NPCs", Some(Admin)) + }, ServerChatCommand::Kit => cmd( vec![Enum("kit_name", KITS.to_vec(), Required)], "Place a set of items into your inventory.", @@ -1078,6 +1080,7 @@ impl ServerChatCommand { ArgumentSpec::SubCommand => "{} {/.*/}", ArgumentSpec::Enum(_, _, _) => "{}", ArgumentSpec::Boolean(_, _, _) => "{}", + ArgumentSpec::Flag(_) => "{}", }) .collect::>() .join(" ") @@ -1148,6 +1151,8 @@ pub enum ArgumentSpec { /// * suggested tab-completion /// * whether it's optional Boolean(&'static str, String, Requirement), + /// The argument is a flag that enables or disables a feature. + Flag(&'static str), } impl ArgumentSpec { @@ -1224,6 +1229,9 @@ impl ArgumentSpec { format!("[{}]", label) } }, + ArgumentSpec::Flag(label) => { + format!("[{}]", label) + }, } } @@ -1239,6 +1247,7 @@ impl ArgumentSpec { | ArgumentSpec::Message(r) | ArgumentSpec::Enum(_, _, r) | ArgumentSpec::Boolean(_, _, r) => *r, + ArgumentSpec::Flag(_) => Requirement::Optional, ArgumentSpec::SubCommand => Requirement::Required, } } diff --git a/voxygen/src/cmd.rs b/voxygen/src/cmd.rs index e5b0e485fc..9dffba8372 100644 --- a/voxygen/src/cmd.rs +++ b/voxygen/src/cmd.rs @@ -101,6 +101,7 @@ impl ClientChatCommand { ArgumentSpec::SubCommand => "{} {/.*/}", ArgumentSpec::Enum(_, _, _) => "{}", ArgumentSpec::Boolean(_, _, _) => "{}", + ArgumentSpec::Flag(_) => "{}", }) .collect::>() .join(" ") @@ -595,6 +596,7 @@ impl TabComplete for ArgumentSpec { .filter(|string| string.starts_with(part)) .map(|c| c.to_string()) .collect(), + ArgumentSpec::Flag(part) => vec![part.to_string()], } } }