From ae62c4a7ce9926d01b3db8c877f5d2caf1f274f1 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Fri, 19 Jul 2019 19:35:08 +0200 Subject: [PATCH] Added basic generic tool collection --- lib/core/tools.psm1 | 1 + lib/core/tools/New-StringTree.psm1 | 19 +++++++++++++++++++ lib/core/tools/Test-Numeric.psm1 | 3 +++ 3 files changed, 23 insertions(+) create mode 100644 lib/core/tools.psm1 create mode 100644 lib/core/tools/New-StringTree.psm1 create mode 100644 lib/core/tools/Test-Numeric.psm1 diff --git a/lib/core/tools.psm1 b/lib/core/tools.psm1 new file mode 100644 index 0000000..de43c34 --- /dev/null +++ b/lib/core/tools.psm1 @@ -0,0 +1 @@ +Import-IcingaDirectoryModules -LibDirectory (Join-Path -Path $PSScriptRoot -ChildPath $MyInvocation.MyCommand.Name) -ForceReload; diff --git a/lib/core/tools/New-StringTree.psm1 b/lib/core/tools/New-StringTree.psm1 new file mode 100644 index 0000000..43e06d7 --- /dev/null +++ b/lib/core/tools/New-StringTree.psm1 @@ -0,0 +1,19 @@ +function New-StringTree() +{ + param( + [int]$Spacing + ) + + if ($Spacing -eq 0) { + return ''; + } + + [string]$spaces = ' \_ '; + + while ($Spacing -gt 1) { + $Spacing -= 1; + $spaces = ' ' + $spaces; + } + + return $spaces; +} diff --git a/lib/core/tools/Test-Numeric.psm1 b/lib/core/tools/Test-Numeric.psm1 new file mode 100644 index 0000000..8d3fca9 --- /dev/null +++ b/lib/core/tools/Test-Numeric.psm1 @@ -0,0 +1,3 @@ +function Test-Numeric ($number) { + return $number -Match "^[\d\.]+$"; +}