aboutsummaryrefslogtreecommitdiff
path: root/azalea-brigadier/src/tree/root_command_node.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-01-09 22:33:45 -0600
committermat <github@matdoes.dev>2022-01-09 22:33:45 -0600
commit315f2258190b33c63df7797a97178019f5aea02b (patch)
tree1ec5f467e7bd42f7aed3aaadbcbc226f8a6ce4f2 /azalea-brigadier/src/tree/root_command_node.rs
parentd56f60c05f316ab4cc37ebe7a9ad4caf91a75de6 (diff)
downloadazalea-drasl-315f2258190b33c63df7797a97178019f5aea02b.tar.xz
add some more stuff from brigadier
Diffstat (limited to 'azalea-brigadier/src/tree/root_command_node.rs')
-rw-r--r--azalea-brigadier/src/tree/root_command_node.rs61
1 files changed, 61 insertions, 0 deletions
diff --git a/azalea-brigadier/src/tree/root_command_node.rs b/azalea-brigadier/src/tree/root_command_node.rs
index e69de29b..004ab6a8 100644
--- a/azalea-brigadier/src/tree/root_command_node.rs
+++ b/azalea-brigadier/src/tree/root_command_node.rs
@@ -0,0 +1,61 @@
+use std::fmt::{Display, Formatter};
+
+use crate::{
+ context::{command_context::CommandContext, command_context_builder::CommandContextBuilder},
+ exceptions::{
+ builtin_exceptions::BuiltInExceptions, command_syntax_exception::CommandSyntaxException,
+ },
+ string_reader::StringReader,
+ suggestion::{suggestions::Suggestions, suggestions_builder::SuggestionsBuilder},
+};
+
+use super::command_node::{BaseCommandNode, CommandNode};
+
+#[derive(Hash, PartialEq, Eq, Debug, Clone)]
+pub struct RootCommandNode<S> {
+ // Since Rust doesn't have extending, we put the struct this is extending as the "base" field
+ pub base: BaseCommandNode<S>,
+}
+
+impl<S> CommandNode<S> for RootCommandNode<S> {
+ fn name(&self) -> &str {
+ ""
+ }
+
+ fn parse(
+ &self,
+ reader: StringReader,
+ context_builder: CommandContextBuilder<S>,
+ ) -> Result<(), CommandSyntaxException> {
+ }
+
+ fn list_suggestions(
+ &self,
+ context: CommandContext<S>,
+ builder: SuggestionsBuilder,
+ ) -> Result<Suggestions, CommandSyntaxException> {
+ Suggestions::empty()
+ }
+
+ fn is_valid_input(&self, input: &str) -> bool {
+ false
+ }
+
+ fn usage_text(&self) -> &str {
+ ""
+ }
+
+ fn create_builder(&self) -> () {
+ panic!("Cannot convert root into a builder");
+ }
+
+ fn get_examples(&self) -> Vec<String> {
+ vec![]
+ }
+}
+
+impl Display for RootCommandNode<()> {
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ write!(f, "<root>")
+ }
+}