From fb12aabf3e8685aaa21185b145caf431ca44b0d4 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 20 Apr 2023 23:44:56 +0200 Subject: global-functions: $DeviceInfo: use $FormatLine --- global-functions.rsc | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 501ea92..45fda9f 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -195,6 +195,7 @@ :global Identity; :global IfThenElse; + :global FormatLine; :local Resource [ /system/resource/get ]; :local RouterBoard; @@ -205,27 +206,27 @@ :local Update [ /system/package/update/get ]; :return ( \ - "Hostname: " . $Identity . \ - "\nBoard name: " . $Resource->"board-name" . \ - "\nArchitecture: " . $Resource->"architecture-name" . \ + [ $FormatLine "Hostname" $Identity ] . "\n" . \ + [ $FormatLine "Board name" ($Resource->"board-name") ] . "\n" . \ + [ $FormatLine "Architecture" ($Resource->"architecture-name") ] . "\n" . \ [ $IfThenElse ($RouterBoard->"routerboard" = true) \ - ("\nModel: " . $RouterBoard->"model" . \ - [ $IfThenElse ([ :len ($RouterBoard->"revision") ] > 0) \ - (" " . $RouterBoard->"revision") ] . \ - "\nSerial number: " . $RouterBoard->"serial-number") ] . \ + ([ $FormatLine "Model" ($RouterBoard->"model") ] . \ + [ $IfThenElse ([ :len ($RouterBoard->"revision") ] > 0) \ + (" " . $RouterBoard->"revision") ] . "\n" . \ + [ $FormatLine "Serial number" ($RouterBoard->"serial-number") ] . "\n") ] . \ [ $IfThenElse ([ :len ($License->"level") ] > 0) \ - ("\nLicense: " . $License->"level") ] . \ - "\nRouterOS:" . \ - "\n Channel: " . $Update->"channel" . \ - "\n Installed: " . $Update->"installed-version" . \ + ([ $FormatLine "License" ($License->"level") ] . "\n") ] . \ + "RouterOS:\n" . \ + [ $FormatLine " Channel" ($Update->"channel") ] . "\n" . \ + [ $FormatLine " Installed" ($Update->"installed-version") ] . "\n" . \ [ $IfThenElse ([ :typeof ($Update->"latest-version") ] != "nothing" && \ $Update->"installed-version" != $Update->"latest-version") \ - ("\n Available: " . $Update->"latest-version") ] . \ + ([ $FormatLine " Available" ($Update->"latest-version") ] . "\n") ] . \ [ $IfThenElse ($RouterBoard->"routerboard" = true && \ $RouterBoard->"current-firmware" != $RouterBoard->"upgrade-firmware") \ - ("\n Firmware: " . $RouterBoard->"current-firmware") ] . \ - "\nRouterOS-Scripts:" . \ - "\n Version: " . $ExpectedConfigVersion); + ([ $FormatLine " Firmware" ($RouterBoard->"current-firmware") ] . "\n") ] . \ + "RouterOS-Scripts:\n" . \ + [ $FormatLine " Version" $ExpectedConfigVersion ]); } # convert line endings, DOS -> UNIX -- cgit v1.2.3-54-g00ecf