🧐 example of automating VLAN creation/removal/inspecting using $mkvlan & friends...

Well the limit of “ROS TUIs” is US-ASCII only, 16 colors, and generally working in 80x24… Without UTF-8 (or god-forbid codepages), the “lines” and “boxes” aren’t possible. So I guess I’m targeting late-1970s/early-1980s style TUIs :wink:

What you got is [/terminal inkey timeout=1s] as an “event loop” and when the timeout= hit, you can do a “refresh” a screen using “:put”. :put does support ANSI colors, using my $CHALK function (or reduced version in $c0lor above) & “\t” will align text to 8 char columns automatically, so you can use that to align columns. $lsbridge above “trims” everything to 7 chars is main “trick” to keep it aligned in columns…

Now what made TUIs slightly easier is the newest :convert and :[de]serialize methods, along with :ask (which isn’t used here). Specifically :convert’s “byte-array”, which let you treat a RouterOS string as a “array of char” & :serialize, essentially, let you do all sorts of array transformations, including using [:convert $myarr to=dsv delimator=“\t”] which is used to print “table rows”. But that why these script require 7.17 (or 7.18 in case of $lsbridge, since that needs options=dsv.remap to deal with a “list-of-dictionaries” from the “print as-value” arrays). Rending the colors does get messy & dealing with alignment – why I’m kinda trying a few different approaches…



I think I’m working to “top” like interface to do “monitoring” which often where using winbox/CLI is sometimes lacking. While “print”'s more advanced follow does let you do a lot - in fact I use a similar trick to @optio’s bridge vlan to show colors in traefik containers log. The problem, I think, is when you want to “watch” a few different parts of the config at the same time in same place at same time where the “normal” CLI print things don’t help.

While MC’s UI styling is a no-go… most of the “command tree” can be render using some combo of “/console/inspect” things with my $QKEYS and $INQUIRE functions. I haven’t done this since there actually a lot of way to use the same RouterOS attributes… But it’s possible with some “rendering function” for data from various “get”/“print as-value” on a loop of /console/inspect to something like MC’s “left side”. Another trick is the out put of a command’s “get” without any attribute return a set of “active” ones, like if IGMP or DHCP sniffer is disabled, the associated timeout/etc attribute aren’t in the array – so that help in rendering things a bit too.

My “needs” are often it takes some complex combo of commands to “show” something meaningfully or setting a bunch of windows, etc etc. The VLAN bridge is one of the main ones it take me parsing a lot of the config the figure out what’s being tagged/untagged… Making $lsbridge interactive – likely named “$topbridge” – is something I’d like to do… Rendering all of RouterOS, well, maybe one day. Basically I’d like to add some kinda UNIX “top” like UI for more commands as the next things. You play a tune using $PIANO - interactive “player piano” or watch something on $ROKU while you wait :wink: