mirror of
https://github.com/nymurbd/MikroTik-scripts.git
synced 2025-08-28 22:08:38 +02:00
global-functions: split off $FormatMultiLines ...
... to format multiple lines from an array.
This commit is contained in:
parent
557823c5c1
commit
4ddc6be585
2 changed files with 23 additions and 8 deletions
|
@ -78,6 +78,7 @@
|
||||||
:local CertVal $1;
|
:local CertVal $1;
|
||||||
|
|
||||||
:global FormatLine;
|
:global FormatLine;
|
||||||
|
:global FormatMultiLines;
|
||||||
:global IfThenElse;
|
:global IfThenElse;
|
||||||
:global ParseKeyValueStore;
|
:global ParseKeyValueStore;
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@
|
||||||
:return ( \
|
:return ( \
|
||||||
[ $FormatLine "Name" ($CertVal->"name") ] . "\n" . \
|
[ $FormatLine "Name" ($CertVal->"name") ] . "\n" . \
|
||||||
[ $IfThenElse ([ :len ($CertVal->"common-name") ] > 0) ([ $FormatLine "CommonName" ($CertVal->"common-name") ] . "\n") ] . \
|
[ $IfThenElse ([ :len ($CertVal->"common-name") ] > 0) ([ $FormatLine "CommonName" ($CertVal->"common-name") ] . "\n") ] . \
|
||||||
[ $IfThenElse ([ :len ($CertVal->"subject-alt-name") ] > 0) ([ $FormatLine "SubjectAltNames" ($CertVal->"subject-alt-name") ] . "\n") ] . \
|
[ $IfThenElse ([ :len ($CertVal->"subject-alt-name") ] > 0) ([ $FormatMultiLines "SubjectAltNames" ($CertVal->"subject-alt-name") ] . "\n") ] . \
|
||||||
[ $FormatLine "Private key" [ $IfThenElse (($CertVal->"private-key") = true) "available" "missing" ] ] . "\n" . \
|
[ $FormatLine "Private key" [ $IfThenElse (($CertVal->"private-key") = true) "available" "missing" ] ] . "\n" . \
|
||||||
[ $FormatLine "Fingerprint" ($CertVal->"fingerprint") ] . "\n" . \
|
[ $FormatLine "Fingerprint" ($CertVal->"fingerprint") ] . "\n" . \
|
||||||
[ $FormatLine "Issuer" ($CertVal->"ca" . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN")) ] . "\n" . \
|
[ $FormatLine "Issuer" ($CertVal->"ca" . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN")) ] . "\n" . \
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
:global EscapeForRegEx;
|
:global EscapeForRegEx;
|
||||||
:global FormatLine;
|
:global FormatLine;
|
||||||
|
:global FormatMultiLines;
|
||||||
:global GetMacVendor;
|
:global GetMacVendor;
|
||||||
:global GetRandom20CharAlNum;
|
:global GetRandom20CharAlNum;
|
||||||
:global GetRandom20CharHex;
|
:global GetRandom20CharHex;
|
||||||
|
@ -339,25 +340,38 @@
|
||||||
|
|
||||||
# format a line for output
|
# format a line for output
|
||||||
:set FormatLine do={
|
:set FormatLine do={
|
||||||
:local Key [ :tostr $1 ];
|
:local Key [ :tostr $1 ];
|
||||||
:local Values [ :toarray $2 ];
|
:local Value [ :tostr $2 ];
|
||||||
:local Indent [ :tonum $3 ];
|
:local Indent [ :tonum $3 ];
|
||||||
:local Spaces " ";
|
:local Spaces " ";
|
||||||
:local Return "";
|
:local Return "";
|
||||||
|
|
||||||
:global EitherOr;
|
:global EitherOr;
|
||||||
:global FormatLine;
|
|
||||||
|
|
||||||
:set Indent [ $EitherOr $Indent 16 ];
|
:set Indent [ $EitherOr $Indent 16 ];
|
||||||
|
|
||||||
:if ([ :len $Key ] > 0) do={ :set Return ($Key . ":"); }
|
:if ([ :len $Key ] > 0) do={ :set Return ($Key . ":"); }
|
||||||
:if ([ :len $Key ] > ($Indent - 2)) do={
|
:if ([ :len $Key ] > ($Indent - 2)) do={
|
||||||
:set Return ($Return . "\n" . [ :pick $Spaces 0 $Indent ] . ($Values->0));
|
:set Return ($Return . "\n" . [ :pick $Spaces 0 $Indent ] . $Value);
|
||||||
} else={
|
} else={
|
||||||
:set Return ($Return . [ :pick $Spaces 0 ($Indent - [ :len $Return ]) ] . ($Values->0));
|
:set Return ($Return . [ :pick $Spaces 0 ($Indent - [ :len $Return ]) ] . $Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:return $Return;
|
||||||
|
}
|
||||||
|
|
||||||
|
# format multiple lines for output
|
||||||
|
:set FormatMultiLines do={
|
||||||
|
:local Key [ :tostr $1 ];
|
||||||
|
:local Values [ :toarray $2 ];
|
||||||
|
:local Indent [ :tonum $3 ];
|
||||||
|
:local Return;
|
||||||
|
|
||||||
|
:global FormatLine;
|
||||||
|
|
||||||
|
:set Return [ $FormatLine $Key ($Values->0) $Indent ];
|
||||||
:foreach Value in=[ :pick $Values 1 [ :len $Values ] ] do={
|
:foreach Value in=[ :pick $Values 1 [ :len $Values ] ] do={
|
||||||
:set Return ($Return . "\n" . [ $FormatLine "" ({$Value}) $Indent ]);
|
:set Return ($Return . "\n" . [ $FormatLine "" $Value $Indent ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
:return $Return;
|
:return $Return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue