Skip to content

Added: printers system#114

Draft
UwUDev wants to merge 5 commits intomainfrom
printers
Draft

Added: printers system#114
UwUDev wants to merge 5 commits intomainfrom
printers

Conversation

@UwUDev
Copy link
Copy Markdown
Collaborator

@UwUDev UwUDev commented Apr 13, 2026

Added a printer system including 3 modes:

  • Pretty
  • Compact
  • Unchanged

I also added a CLI arg (--printer & --pr) that uses the Pretty mode by default

I implemented Printer for the powershell Linter just to support the new feature but it would be nice to create a PowershellPrinter that supports the 3 modes.

impl Printer for Linter {
type Language = Powershell;
fn print<S>(&mut self, tree: &Tree<'_, S>, mode: PrinterMode) -> MinusOneResult<String>
where
S: Storage<Component = Self::Language> + Default,
{
self.output.clear();
self.tab = vec![String::new()];
self.is_param_block = false;
self.statement_block_tab.clear();
self.is_multiline = true;
self.new_line_chr = match mode {
PrinterMode::Pretty => "\n".to_string(),
PrinterMode::Compact => " ".to_string(),
PrinterMode::Unchanged => " ".to_string(),
};
tree.apply(self)?;
Ok(self.output.trim().to_string())
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a pretty printer Add option to make the linter "minified" or "pretty"

1 participant