From 003a239733efc95f89716f1c7d93aed018691b41 Mon Sep 17 00:00:00 2001 From: Maurice MJ de Jong Date: Tue, 6 Oct 2020 16:06:12 +0200 Subject: [PATCH] New Release v1.0.11 !deploy (#22) - Renamed Convert-StringToShort to Convert-ToShortString - fixed output value return --- src/Public/3 | 1 + src/Public/Convert-ToShortString.ps1 | 51 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/Public/3 create mode 100644 src/Public/Convert-ToShortString.ps1 diff --git a/src/Public/3 b/src/Public/3 new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/src/Public/3 @@ -0,0 +1 @@ +4 diff --git a/src/Public/Convert-ToShortString.ps1 b/src/Public/Convert-ToShortString.ps1 new file mode 100644 index 0000000..16aa44e --- /dev/null +++ b/src/Public/Convert-ToShortString.ps1 @@ -0,0 +1,51 @@ +function Convert-ToShortString { + <# + .SYNOPSIS + returns an abreviate from the string you provide, try to get a 3 letter word + .EXAMPLE + PS> Get-ShortEnvironment -StringInput 'Test' + tst + PS>_ + + .PARAMETER StringInput + The string of the text file you'd like to make shorter + If the word your provide is a well known one I try to make the best of it + + #> + [CmdletBinding()] + param ( + # this where you provide the string + [Parameter(Mandatory = $true, ValueFromPipeline)] + [string]$StringInput + ) + + begin { + # we do nothing here noting to initialise + } + + process { + if($StringInput.Length -gt 3 ) + { + Switch ($StringInput) + { + "development"{ return "dev" } + "production"{ return "prd" } + "prod" { return "prd" } + "testing" { return "tst" } + "test" { return "tst" } + "staging" { return "stg" } + "testing" { return "tst" } + "acceptance"{ return "acc" } + default { return ($StringInput.ToLower() -replace '[aeiouy]').SubString(0,3) } + } + } + else + { + return $StringInput.ToLower() + } + } + + end { + # we do nothing here noting to cleanup + } +} \ No newline at end of file