mec - Another mushcode un/formater
-
I've published an initial idea for perl based mushcode formater / unformater to github. The general idea is to take mushcode scripts and make them more readable for editing by breaking up the code into multiple lines following various arbitrary rules. Once your done editing your code, you unformat the code for upload to a mush.
Arbitrary Rules:
- Do not split up short strings/functions. Code that spans several pages that doesn't need to is unreadable too.
- Wrap long strings of text.
- Spaces at the end of a line are significant after formatting.
- Spaces at the beginning of a line are not significant after formatting.
- Make sure formatted text can be unformatted back to the original without modification.
- Functions arguments will be split and indented.
The Arguments of the function will be indented so that it lines up with the end of the function name on the next line. - Some commands will be indented in a way that I think is more readable. Commands currently with special formatting are: @switch/@select, @dolist, &, @while, think, and @pemit
Function Example:
&match com=[first([extract(u(gdb),match(u(gdb),first(%0)),1)][extract(u(gdb),match(u(gdb),*[first(%0)]*),1)])] Becomes: &match com= [first([extract(u(gdb), match(u(gdb),first(%0)), 1 )] [extract(u(gdb), match(u(gdb),*[first(%0)]*), 1 )] )]
Command Example:
&short com=$=*:@dolist [u(lwho,u(first))]={@pemit before(##,_)=[u(format,%#,##,%0)]};@pemit %#=[switch(u(first),,v(msg_none),MONITOR,v(msg_monitor))]
Becomes:
&short com=$=*: @dolist [u(lwho,u(first))]= { @pemit before(##,_)= [u(format,%#,##,%0)] }; @pemit %#= [switch(u(first),,v(msg_none),MONITOR,v(msg_monitor))]