From 4b3670fc6b037911be8a1320b5994eb89886e41f Mon Sep 17 00:00:00 2001 From: Qrius Date: Thu, 26 Sep 2024 00:11:05 +0200 Subject: Add man pages, add array function to SMP --- src/macro_processor/macro_processor.rs | 12 ++++++++++++ src/skaldpress/parseopts.rs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/macro_processor/macro_processor.rs b/src/macro_processor/macro_processor.rs index 85bf8e1..96d5471 100644 --- a/src/macro_processor/macro_processor.rs +++ b/src/macro_processor/macro_processor.rs @@ -246,6 +246,7 @@ pub enum MacroType { ), /// Will be expanded in-place to the String String(String), + Array(Vec), } /// Possible parser states @@ -339,6 +340,17 @@ impl MacroProcessor { self.macros.insert(name, macro_expansion); } + pub fn array_push(&mut self, name: String, element: MacroType) -> Result<(), SMPError> { + let Some(macro_body) = self.macros.get_mut(&name) else { + return Err(SMPError::UnknownError(4, None)); + }; + let MacroType::Array(array) = macro_body else { + return Err(SMPError::UnknownError(5, None)); + }; + array.push(element); + Ok(()) + } + /// This expands a macro definition, and it executes builtin functions, like define /// /// # Arguments diff --git a/src/skaldpress/parseopts.rs b/src/skaldpress/parseopts.rs index 36fbf13..3985684 100644 --- a/src/skaldpress/parseopts.rs +++ b/src/skaldpress/parseopts.rs @@ -135,7 +135,7 @@ pub fn parseopts() -> OptsBuilder { } else { arg_name = arg.clone(); match arg_name.as_str() { - "out" | "source" | "templates" => { + "out" | "source" | "templates" | "filter" => { arg_value = it.next(); } _ => (), -- cgit v1.2.3