diff --git a/src/datapack/command/execute.rs b/src/datapack/command/execute.rs index dfbab5b..d15207d 100644 --- a/src/datapack/command/execute.rs +++ b/src/datapack/command/execute.rs @@ -186,23 +186,31 @@ impl Execute { command => command .compile(options, global_state, function_state) .into_iter() - .map(|c| (true, prefix.clone() + "run " + &c)) + .map(|c| map_run_cmd(c, &prefix)) .collect(), }, Self::Runs(commands) if !require_grouping => commands .iter() .flat_map(|c| c.compile(options, global_state, function_state)) - .map(|c| (true, prefix.clone() + "run " + &c)) + .map(|c| map_run_cmd(c, &prefix)) .collect(), Self::Runs(commands) => Command::Group(commands.clone()) .compile(options, global_state, function_state) .into_iter() - .map(|c| (true, prefix.clone() + "run " + &c)) + .map(|c| map_run_cmd(c, &prefix)) .collect(), } } } +fn map_run_cmd(cmd: String, prefix: &str) -> (bool, String) { + if cmd.starts_with('#') { + (false, cmd) + } else { + (true, prefix.to_string() + "run " + &cmd) + } +} + fn format_execute( prefix: String, new: &str, diff --git a/src/datapack/command/mod.rs b/src/datapack/command/mod.rs index 313b2b0..d46c720 100644 --- a/src/datapack/command/mod.rs +++ b/src/datapack/command/mod.rs @@ -22,6 +22,8 @@ pub enum Command { Execute(Execute), /// Group of commands to be called instantly after each other Group(Vec), + /// Comment to be added to the function + Comment(String), } impl Command { @@ -42,6 +44,7 @@ impl Command { Self::Debug(message) => compile_debug(message, options), Self::Execute(ex) => ex.compile(options, global_state, function_state), Self::Group(commands) => compile_group(commands, options, global_state, function_state), + Self::Comment(comment) => vec!["#".to_string() + comment], } } }