Downloads:
51
Downloads of v 0.1.0:
51
Last Update:
13 Oct 2020
Package Maintainer(s):
Software Author(s):
- Baptiste Cabrera
Tags:
text format windows linux macosBca.Text
Downloads:
51
Downloads of v 0.1.0:
51
Maintainer(s):
Software Author(s):
- Baptiste Cabrera
Bca.Text
- 1
- 2
- 3
All Checks are Passing
3 Passing Tests
This package was rejected on 15 Dec 2020. The reviewer chocolatey-ops has listed the following reason(s):
Powershell module to format text and display messages with custom colors.
#
# Module manifest for module 'Bca.Text'
#
# Generated by: Baptiste Cabrera
#
# Generated on: 9/25/2020
#
@{
# Script module or binary module file associated with this manifest.
RootModule = 'Bca.Text'
# Version number of this module.
ModuleVersion = '0.1.0'
# Supported PSEditions
# CompatiblePSEditions = @()
# ID used to uniquely identify this module
GUID = '2ac55930-7dbe-44e0-a2c9-95212560c346'
# Author of this module
Author = 'Baptiste Cabrera'
# Company or vendor of this module
CompanyName = 'Bca'
# Copyright statement for this module
Copyright = '(c) 2020 Bca. All rights reserved.'
# Description of the functionality provided by this module
Description = 'Powershell module to format text and display messages with custom colors.'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.1'
# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# CLRVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'ConvertTo-Color', 'Format-String', 'Show-Choice', 'Show-Error',
'Show-Information', 'Show-Message', 'Show-Question', 'Show-Success',
'Show-Unspecified', 'Show-Warning', 'Split-String', 'Test-Color',
'Write-HostRgb'
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
# Variables to export from this module
# VariablesToExport = @()
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
#projectSourceUrl of this module
projectSourceUrl = 'https://github.com/baptistecabrera/bca-text/tree/master/src'
#docsUrl of this module
docsUrl = 'https://github.com/baptistecabrera/bca-text/tree/master/doc'
#repositoryUrl of this module
repositoryUrl = 'https://github.com/baptistecabrera/bca-text.git'
#License of this module
License = 'MIT'
#packageSourceUrl of this module
packageSourceUrl = 'https://github.com/baptistecabrera/bca-text/tree/master/src'
#bugTrackerUrl of this module
bugTrackerUrl = 'https://github.com/baptistecabrera/bca-text/issues'
#mailingListUrl of this module
mailingListUrl = 'https://github.com/baptistecabrera/bca-text/issues'
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'text','format','Windows','Linux','MacOS'
# A URL to the license for this module.
LicenseUri = 'https://github.com/baptistecabrera/bca-text/blob/master/LICENSE'
# A URL to the main website for this project.
ProjectUri = 'https://github.com/baptistecabrera/bca-text'
# A URL to an icon representing this module.
IconUri = 'https://www.powershellgallery.com/Content/Images/Branding/packageDefaultIcon.png'
# ReleaseNotes of this module
ReleaseNotes = '0.1.0:
- First version supports:
- Show message, information, success, warning, error, question (with or without choices, supporting default choice and help) and unspecified;
- Format string (left, right and center align);
- Split string on multiple lines;
- Convert and test colors;
- Write on host using custom colors (as opposed to only supporting ConsoleColor).'
# Prerelease string of this module
# Prerelease = ''
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false
# External dependent modules of this module
# ExternalModuleDependencies = @()
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}
try
{
# Importing Localized Data if present (fallback to en-US)
if (Test-Path (Join-Path $PSScriptRoot LocalizedData))
{
$script:LocalizedData = Import-LocalizedData -BaseDirectory (Join-Path $PSScriptRoot LocalizedData) -ErrorAction SilentlyContinue
if (!$?) { $script:LocalizedData = Import-LocalizedData -UICulture en-US -BaseDirectory (Join-Path $PSScriptRoot LocalizedData) }
}
# Gets public and private function definition files.
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -Recurse -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -Recurse -ErrorAction SilentlyContinue )
# Dot source the files
foreach ($File in @($Public + $Private))
{
try
{
. $File.FullName
}
catch
{
Write-Error -Message ($script:LocalizedData.ImportModule.Error.ImportError.Message -f $File.BaseName, $_) -Category OperationStopped -CategoryActivity $MyInvocation.MyCommand -TargetName $File.BaseName -TargetType $script:LocalizedData.ImportModule.Error.ImportError.Target -Exception OperationStoppedException
}
}
# Exports public functions and their aliases
Export-ModuleMember -Function $Public.BaseName -Alias *
}
catch
{
Write-Error $_
}
if (Test-Path (Join-Path $PSScriptRoot LocalizedData))
{
$global:TestLocalizedData = Import-LocalizedData -BaseDirectory (Join-Path $PSScriptRoot LocalizedData) -ErrorAction SilentlyContinue
if (!$?) { $global:TestLocalizedData = Import-LocalizedData -UICulture en-US -BaseDirectory (Join-Path $PSScriptRoot LocalizedData) }
}
Describe $global:TestLocalizedData.Module.Describe {
BeforeAll {
$ParentDirectory = Split-Path $PSScriptRoot -Parent
$Directory = Split-Path $PSScriptRoot -Leaf
if ([version]::TryParse($Directory, [ref]$null)) { $ModuleName = Split-Path $ParentDirectory -Leaf }
else { $ModuleName = $Directory }
}
It $global:TestLocalizedData.Module.ImportModule {
try
{
Import-Module (Join-Path $PSScriptRoot ("{0}.psd1" -f $ModuleName)) -Force
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.Module.CommandCheck {
$Commands = Get-Command -Module $ModuleName
$Commands.Count | Should -BeGreaterThan 0
}
}
Describe $global:TestLocalizedData.Message.Describe -Tags "WindowsOnly" {
It $global:TestLocalizedData.Message.Tests {
try
{
Write-HostRgb " "
Show-Error -Message "This is an error (with no width specified)."
Write-HostRgb " "
Show-Success -Message "This is a success (with a width of 50)." -Width 50
Write-HostRgb " "
Show-Warning -Message "This is warning (with no width specified and a left and right padding)." -PaddingLeft 3 -PaddingRight 2
Write-HostRgb " "
Show-Information -Message "This is an info (with a width of 20 and left padding)." -Width 20 -PaddingLeft 3
Write-HostRgb " "
Show-Unspecified -Message "This is an unspecified message (with truncated words)." -Width 10
Write-HostRgb " "
Show-Message -Message "This is a custom message (with a width of 30)." -PrimaryColor Magenta -SecondaryColor @{ R = 125; G = 125; B = 125 } -TextColor Cyan -Width 30
Write-HostRgb " "
Show-Message -Message "This is another very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long custom message (with no width specified)." -PrimaryColor Blue -SecondaryColor DarkBlue -TextColor Cyan
Write-HostRgb " "
Write-HostRgb "This is a a test with NoNewLine: " -NoNewLine
Show-Message -Message "This is a custom message (after NoNewLine with no width specified)." -PrimaryColor Magenta -SecondaryColor @{ R = 125; G = 125; B = 125 } -TextColor Cyan
Write-HostRgb " "
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
}
}
Describe $global:TestLocalizedData.Question.Describe -Tags "WindowsOnly" {
It $global:TestLocalizedData.Question.QuestionChoice {
Mock -CommandName Read-Host -ModuleName $ModuleName -MockWith { return "1" }
try
{
$Answer = Show-Question -Question "Are you sure?" -Choice @("Yes", "No") -Prompt "Answer"
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$Answer | Should -BeExactly "0"
}
It $global:TestLocalizedData.Question.QuestionDefaultChoice {
Mock -CommandName Read-Host -ModuleName $ModuleName -MockWith { "" }
try
{
$Answer = Show-Question -Question "Are you sure?" -Choice @("Yes", "No") -Default 0 -PaddingLeft 2 -PaddingRight 1 -Help "This is a helpful message"
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$Answer | Should -BeExactly "0"
}
It $global:TestLocalizedData.Question.QuestionDefaultChoice {
Mock -CommandName Read-Host -ModuleName $ModuleName -MockWith { Get-Random @("", "?") }
try
{
$Answer = Show-Question -Question "Are you sure?" -Choice @("Yes", "No") -Default 0 -PaddingLeft 2 -PaddingRight 1 -Help "This is a helpful message"
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$Answer | Should -BeExactly "0"
}
It $global:TestLocalizedData.Question.QuestionDefaultChoice {
Mock -CommandName Read-Host -ModuleName $ModuleName -MockWith { Get-Random @("", "?") }
try
{
$Answer = Show-Question -Question "Are you sure?" -Choice @("Yes", "No") -Default 0 -PaddingLeft 2 -PaddingRight 1 -Help "This is a helpful message"
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$Answer | Should -BeExactly "0"
}
It $global:TestLocalizedData.Question.QuestionDefaultChoice {
Mock -CommandName Read-Host -ModuleName $ModuleName -MockWith { Get-Random @("", "?") }
try
{
$Answer = Show-Question -Question "Are you sure?" -Choice @("Yes", "No") -Default 0 -PaddingLeft 2 -PaddingRight 1 -Help "This is a helpful message"
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$Answer | Should -BeExactly "0"
}
It $global:TestLocalizedData.Question.QuestionNoChoice {
Mock -CommandName Read-Host -ModuleName $ModuleName -MockWith { return "answer" }
try
{
$Answer = Show-Question -Question "Question?"
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$Answer | Should -BeExactly "answer"
}
It $global:TestLocalizedData.Question.QuestionNoChoice {
Mock -CommandName Read-Host -ModuleName $ModuleName -MockWith { Get-Random @("answer", "?") }
try
{
$Answer = Show-Question -Question "Question?" -Help "Help"
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$Answer | Should -BeExactly "answer"
}
It $global:TestLocalizedData.Question.QuestionNoChoice {
Mock -CommandName Read-Host -ModuleName $ModuleName -MockWith { Get-Random @("answer", "?") }
try
{
$Answer = Show-Question -Question "Question?" -Help "Help"
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$Answer | Should -BeExactly "answer"
}
It $global:TestLocalizedData.Question.QuestionNoChoice {
Mock -CommandName Read-Host -ModuleName $ModuleName -MockWith { Get-Random @("answer", "?") }
try
{
$Answer = Show-Question -Question "Question?" -Help "Help"
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$Answer | Should -BeExactly "answer"
}
}
Describe $global:TestLocalizedData.ConvertTest.DescribeConvert {
BeforeAll {
$Color = [system.ConsoleColor]::Red
$String = "Red"
$Hex = "#ff0000"
$Hex2 = "ff0000"
$Hash = @{ R = 1; G = 2; B = 3 }
$Object = New-Object -TypeName PsObject -Property $Hash
$IntArray = @( 125, 123, 124 )
$StringArray = @( "125", "123", "124" )
}
It $global:TestLocalizedData.ConvertTest.Color {
try
{
$ResultColor = $Color | ConvertTo-Color
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$ResultColor | Should -BeExactly "Red"
}
It $global:TestLocalizedData.ConvertTest.String {
try
{
$ResultColor = $String | ConvertTo-Color
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.Hex {
try
{
$ResultColor = $Hex | ConvertTo-Color
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.Hex2 {
try
{
$ResultColor = $Hex2 | ConvertTo-Color
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.Hash {
try
{
$ResultColor = $Hash | ConvertTo-Color
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.Object {
try
{
$ResultColor = $Object | ConvertTo-Color
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.IntArray {
try
{
$Result = ConvertTo-Color -Color $IntArray
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.StringArray {
try
{
$Result = ConvertTo-Color -Color $StringArray
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
}
}
Describe $global:TestLocalizedData.ConvertTest.DescribeConvert {
BeforeAll {
$Color = "toto"
$String = "plop"
$Hex = "#ffzz00"
$Hex2 = "ffzz00"
$Hash = @{ R = 260; G = 2; B = 3 }
$Hash2 = @{ G = 2; B = 3 }
$Object = New-Object -TypeName PsObject -Property $Hash
$Object2 = New-Object -TypeName PsObject -Property $Hash2
$IntArray = @( 300, 123, 124 )
$StringArray = @( "125", "300", "124" )
$Float = 1.3
}
It $global:TestLocalizedData.ConvertTest.Color {
try
{
$ResultColor = $Color | ConvertTo-Color -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.String {
try
{
$ResultColor = $String | ConvertTo-Color -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Hex {
try
{
$ResultColor = $Hex | ConvertTo-Color -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Hex2 {
try
{
$ResultColor = $Hex2 | ConvertTo-Color -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Hash {
try
{
$ResultColor = $Hash | ConvertTo-Color -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Hash {
try
{
$ResultColor = $Hash2 | ConvertTo-Color -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Object {
try
{
$ResultColor = $Object | ConvertTo-Color -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Object {
try
{
$ResultColor = $Object2 | ConvertTo-Color -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.IntArray {
try
{
$Result = ConvertTo-Color -Color $IntArray -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.StringArray {
try
{
$Result = ConvertTo-Color -Color $StringArray -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Float {
try
{
$ResultColor = $Float | ConvertTo-Color -ErrorAction Stop
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $false
}
}
Describe $global:TestLocalizedData.ConvertTest.DescribeTest {
BeforeAll {
$Color = [system.ConsoleColor]::Red
$String = "Red"
$Hex = "#ff0000"
$Hex2 = "ff0000"
$Hash = @{ R = 1; G = 2; B = 3 }
$Object = New-Object -TypeName PsObject -Property $Hash
$IntArray = @( 125, 123, 124 )
$StringArray = @( "125", "123", "124" )
}
It $global:TestLocalizedData.ConvertTest.Color {
try
{
$Result = $Color | Test-Color
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.String {
try
{
$Result = $String | Test-Color
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.Hex {
try
{
$Result = $Hex | Test-Color
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.Hex2 {
try
{
$Result = $Hex2 | Test-Color
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.Hash {
try
{
$Result = $Hash | Test-Color
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.Object {
try
{
$Result = $Object | Test-Color
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.IntArray {
try
{
$Result = Test-Color -Color $IntArray
}
catch { $Result = $false }
$Result | Should -Be $true
}
It $global:TestLocalizedData.ConvertTest.StringArray {
try
{
$Result = Test-Color -Color $StringArray
}
catch { $Result = $false }
$Result | Should -Be $true
}
}
Describe $global:TestLocalizedData.ConvertTest.DescribeTest {
BeforeAll {
$Color = "toto"
$String = "plop"
$Hex = "#ffzz00"
$Hex2 = "ffzz00"
$Hash = @{ R = 260; G = 2; B = 3 }
$Hash2 = @{ G = 2; B = 3 }
$Object = New-Object -TypeName PsObject -Property $Hash
$Object2 = New-Object -TypeName PsObject -Property $Hash2
$IntArray = @( 300, 123, 124 )
$StringArray = @( "125", "300", "124" )
$Float = 1.3
}
It $global:TestLocalizedData.ConvertTest.Color {
try
{
$Result = $Color | Test-Color -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.String {
try
{
$Result = $String | Test-Color -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Hex {
try
{
$Result = $Hex | Test-Color -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Hex2 {
try
{
$Result = $Hex2 | Test-Color -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Hash {
try
{
$Result = $Hash | Test-Color -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Hash {
try
{
$Result = $Hash2 | Test-Color -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Object {
try
{
$Result = $Object | Test-Color -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Object {
try
{
$Result = $Object2 | Test-Color -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.IntArray {
try
{
$Result = Test-Color -Color $IntArray -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.StringArray {
try
{
$Result = Test-Color -Color $StringArray -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
It $global:TestLocalizedData.ConvertTest.Float {
try
{
$Result = $Float | Test-Color -ErrorAction Stop
}
catch { $Result = $true }
$Result | Should -Be $false
}
}
Describe $global:TestLocalizedData.Format.Describe {
BeforeAll {
$BaseString = "test"
$Width = 12
$LeftString = "test"
$RightString = " test"
$CenterString = " test "
}
It $global:TestLocalizedData.Format.Left {
try
{
$String = Format-String -String $BaseString -Width $Width -Align Left
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$String | Should -BeExactly $LeftString
}
It $global:TestLocalizedData.Format.Right {
try
{
$String = Format-String -String $BaseString -Width $Width -Align Right
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$String | Should -BeExactly $RightString
}
It $global:TestLocalizedData.Format.Center {
try
{
$String = Format-String -String $BaseString -Width $Width -Align Center
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$String | Should -BeExactly $CenterString
}
It $global:TestLocalizedData.Format.CenterPadding {
try
{
$String = Format-String -String $BaseString -Width ($Width + 4) -Align Center -PaddingLeft 2 -PaddingRight 2
$Result = $true
}
catch { $Result = $false }
$Result | Should -Be $true
$String | Should -BeExactly " $CenterString "
}
}
$ErrorActionPreference = "Stop"
$ModuleName = $env:ChocolateyPackageTitle
$ModuleVersion = $env:ChocolateyPackageVersion
$ModulePath = Get-Content (Join-Path $PSScriptRoot "installPath.txt") -ErrorAction SilentlyContinue
Remove-Module -Name $ModuleName -Force -ErrorAction SilentlyContinue
if (!$ModulePath) { Write-Warning "No module path found, '$ModuleName' may have been manually uninstalled." }
$ModulePath | ForEach-Object {
$ParentModulePath = (Split-Path $_ -Parent)
Write-Verbose "Module path is '$_'."
if ((Test-Path $_))
{
Write-Verbose "Emtpying directory '$_'."
Remove-Item -Path $_ -Recurse -Force
}
else { Write-Warning "Path '$_' not found, '$ModuleName' may have been manually uninstalled." }
if ((Test-Path $ParentModulePath) -and ((Get-ChildItem -Path $ParentModulePath | Measure-Object).Count -eq 0))
{
Write-Verbose "No file left in '$($ParentModulePath)', removing folder."
Remove-Item -Path $ParentModulePath -Recurse -Force
}
}
Write-Verbose "Module '$ModuleName' version $ModuleVersion uninstalled."
function Write-HostRgb
{
<#
.SYNOPSIS
Writes a message to the host.
.DESCRIPTION
Writes a message to the host console.
.LINK
Write-Host
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $false, ValueFromPipeline = $true)]
[object] $Object,
[Parameter(Mandatory = $false)]
$BackGroundColor,
[Parameter(Mandatory = $false)]
$ForeGroundColor,
[Parameter(Mandatory = $false)]
[object] $Separator,
[Parameter(Mandatory = $false)]
[switch] $NoNewLine
)
try
{
if ($BackGroundColor) { $BackGroundColor = ConvertTo-Color -Color $BackGroundColor -ErrorAction Stop }
if ($ForeGroundColor) { $ForeGroundColor = ConvertTo-Color -Color $ForeGroundColor -ErrorAction Stop }
if (($BackGroundColor -and ($BackGroundColor.GetType().Name -ne "ConsoleColor")) -or ($ForeGroundColor -and ($ForeGroundColor.GetType().Name -ne "ConsoleColor")))
{
$EscapeChar = [char]27
$BackGroundColorString = ""
$ForeGroundColorString = ""
if ($BackGroundColor.GetType().Name -in "Hashtable", "PSCustomObject")
{
$BackGroundColorString = "48;2;{0};{1};{2}" -f $BackGroundColor.R, $BackGroundColor.G, $BackGroundColor.B
$PSBoundParameters.Remove("BackGroundColor") | Out-Null
}
if ($ForeGroundColor.GetType().Name -in "Hashtable", "PSCustomObject")
{
$ForeGroundColorString = "38;2;{0};{1};{2}" -f $ForeGroundColor.R, $ForeGroundColor.G, $ForeGroundColor.B
$PSBoundParameters.Remove("ForeGroundColor") | Out-Null
}
if ($BackGroundColorString -and $ForeGroundColorString) { $ColorString = "{0};{1}" -f $ForeGroundColorString, $BackGroundColorString }
else { $ColorString = "{0}{1}" -f $ForeGroundColorString, $BackGroundColorString }
$Object = "{0}[{1}m{2}{0}[0m" -f $EscapeChar, $ColorString, $Object
$PSBoundParameters.Object = $Object
}
Write-Host @PSBoundParameters
}
catch { Write-Error $_ }
}
function Test-Color
{
<#
.SYNOPSIS
Tests a color.
.DESCRIPTION
Tests a color.
.PARAMETER Color
An object representing the color.
This can be
- a ConsoleColor,
- a String with the name of the ConsoleColor,
- a String containing the hexadecimal color (with or without '#'),
- an Hashtable or PSCustomObject containing R, G and B members,
- an Integer array containing the values for R, G and B (in this order).
.INPUTS
System.Management.Automation.PSCustomObject
You can pipe a value for the color to this cmdlet.
.INPUTS
System.ConsoleColor
You can pipe a value for the color to this cmdlet.
.INPUTS
System.Hashtable
You can pipe a value for the color to this cmdlet.
.INPUTS
System.String
You can pipe a value for the color to this cmdlet.
.OUTPUTS
System.Boolean
Returns a Boolean describing if the color is correct or not
.EXAMPLE
Test-Color -Color "Red"
Description
-----------
This example will test the color with value "Red".
.NOTES
Arrays can not be piped to this function as they will be unwraped.
.LINK
ConvertTo-Color
#>
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
$Color
)
switch -Regex ($Color.GetType().Name)
{
"ConsoleColor" { $true }
"Hashtable|PSCustomObject"
{
if (($Color.R -in 0..255) -and ($Color.G -in 0..255) -and ($Color.B -in 0..255)) { $true }
else { $false }
}
"Object\[\]"
{
if (($Color.Count -eq 3) -and ($Color[0] -in 0..255) -and ($Color[1] -in 0..255) -and ($Color[2] -in 0..255)) { $true }
else { $false }
}
"String"
{
if ($Color.StartsWith("#")) { $Color = $Color.Substring(1) }
if ($Color -match '[A-Fa-f0-9]{6}')
{
$ColorHash = @{
R = [convert]::ToInt32($Color.Substring(0, 2), 16);
G = [convert]::ToInt32($Color.Substring(2, 2), 16);
B = [convert]::ToInt32($Color.Substring(4, 2), 16)
}
$ColorHash | Test-Color
}
else
{
try
{
[System.ConsoleColor] $Color = $Color
$true
}
catch { $false }
}
}
default { $false }
}
}
function Split-String
{
<#
.SYNOPSIS
Splits a string.
.DESCRIPTION
Splits a string to make it fit in a specified width.
.PARAMETER String
A string containing the string to split.
.PARAMETER Width
An integer specifying the width to fit to.
.PARAMETER PaddingLeft
An integer specifying the left padding of the message.
.PARAMETER PaddingRight
An integer specifying the right padding of the message.
.INPUTS
System.String
You can pipe a value for the string to this cmdlet.
.OUTPUTS
System.String[]
Returns a String array containing the split strings.
.NOTES
.LINK
Show-Message
#>
[CmdLetBinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string] $String,
[Parameter(Mandatory = $false)]
[int] $Width = $Host.UI.RawUI.MaxWindowSize.Width - $Host.UI.RawUI.CursorPosition.X,
[Parameter(Mandatory = $false)]
[int] $PaddingLeft,
[Parameter(Mandatory = $false)]
[int] $PaddingRight,
[Parameter(Mandatory = $false)]
[String] $PaddingChar = " ",
[Parameter(Mandatory = $false)]
[int] $Offset
)
$Message = $String
$String = ""
$Strings = @()
$PaddingSize = $Offset + $PaddingLeft + $PaddingRight
if ((($Message.Length + $PaddingSize) -gt $Width) -or ($Width -gt $Host.UI.RawUI.MaxWindowSize.Width))
{
$Message.Split(" ") | ForEach-Object {
$Word = $_
if (($String.Length + $Word.Length + 1) -ge ($Width - $PaddingSize))
{
if ($String) { $Strings += "{0}{1}{0}" -f $PaddingChar, $String.PadRight($Width - $PaddingSize, $PaddingChar) }
$String = ""
if ($Word.Length -ge ($Width - $PaddingSize))
{
$Remaining = $Word
while ($Remaining)
{
if ($Remaining.Length -ge ($Width - $PaddingSize))
{
$TruncatedString = $Remaining.Substring(0, $Width - $PaddingSize)
$Remaining = $Remaining.Substring($Width - $PaddingSize)
}
else
{
$TruncatedString = $Remaining
$Remaining = ""
}
$Strings += "{0}{1}{0}" -f $PaddingChar, $TruncatedString.PadRight($Width - $PaddingSize, $PaddingChar)
}
$Word = ""
}
}
if ($Word)
{
if ($String) { $String += " " }
$String += $Word
}
}
if ($String) { $Strings += "{0}{1}{0}" -f $PaddingChar, $String.PadRight($Width - $PaddingSize, $PaddingChar) }
}
else { $Strings += "{0}{1}{0}" -f $PaddingChar, $Message.PadRight($Width - $PaddingSize, $PaddingChar) }
return $Strings
}
function Show-Question
{
<#
.SYNOPSIS
Shows a question message.
.DESCRIPTION
Shows a question message to the console.
.PARAMETER Question
A string containing the question to show.
.PARAMETER Prompt
A string containing the prompt to show.
.PARAMETER Choice
A string array containing the possible choices.
If not choice is specified, the answer will be user input.
.PARAMETER Help
A string containing a help message.
.PARAMETER Default
An integer containing the index of the default choice.
.PARAMETER Width
An integer specifying the width of the message.
.PARAMETER PaddingLeft
An integer specifying the left padding of the message.
.PARAMETER PaddingRight
An integer specifying the right padding of the message.
.OUTPUTS
System.Int32
Returns an integer containing the index of the choice selected if choices are provided.
.OUTPUTS
System.String
Returns a string containing the the user's answer if no choices are provided.
.EXAMPLE
Show-Question -Question "Is this a question?" -Choice @( "Yes", "No" )
Description
-----------
This example will show the question "Is this a question?" and returns the choice selected.
.EXAMPLE
Show-Question -Question "Can you tell me more about you?"
Description
-----------
This example will show the question "Can you tell me more about you?" and returns the user input.
.NOTES
.LINK
Show-Message
.LINK
Show-Choice
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Question,
[Parameter(Mandatory = $false)]
[string] $Prompt,
[Parameter(Mandatory = $false)]
[string[]] $Choice,
[Parameter(Mandatory = $false)]
[string] $Help = "",
[Parameter(Mandatory = $false)]
[int] $Width = $Host.UI.RawUI.MaxWindowSize.Width - $Host.UI.RawUI.CursorPosition.X,
[Parameter(Mandatory = $false)]
[int] $Default = -1,
[Parameter(Mandatory = $false)]
[int] $PaddingLeft,
[Parameter(Mandatory = $false)]
[int] $PaddingRight
)
Show-Message -Message $Question -Type Question -Width $Width -PaddingLeft $PaddingLeft -PaddingRight $PaddingRight
if ($Choice) { Show-Choice -Choice $Choice -Prompt $Prompt -Width $Width -PaddingLeft $PaddingLeft -PaddingRight $PaddingRight -Default $Default -Help $Help }
else
{
$Answer = " "
if (!$Prompt) { $Prompt = $script:LocalizedData.Choice.YourAnswer }
if ($Help)
{
$DisplayPrompt = "{0} {1}" -f $Prompt, ($script:LocalizedData.Choice.TypeHelp -f "?")
while (($Answer -eq "?") -or ($Answer -eq " "))
{
$Answer = Read-Host -Prompt (Format-String -String $DisplayPrompt -Widt $Width -PaddingLeft $PaddingLeft -PaddingRight $PaddingRight)
if (($Answer -eq "?") -and $Help)
{
Show-Information -Message $Help -Widt $Width -PaddingLeft $PaddingLeft -PaddingRight $PaddingRight
$Answer = " "
}
}
}
else { $Answer = Read-Host -Prompt (Format-String -String $Prompt -Widt $Width -PaddingLeft $PaddingLeft -PaddingRight $PaddingRight) }
$Answer
}
}
function Show-Error
{
<#
.SYNOPSIS
Shows an error message.
.DESCRIPTION
Shows an error message to the console.
.PARAMETER Message
A string containing the message to show.
.PARAMETER Width
An integer specifying the width of the message.
.PARAMETER PaddingLeft
An integer specifying the left padding of the message.
.PARAMETER PaddingRight
An integer specifying the right padding of the message.
.EXAMPLE
Show-Error -Message "This is an error"
Description
-----------
This example will show the error "This is an error".
.NOTES
.LINK
Show-Message
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Message,
[Parameter(Mandatory = $false)]
[int] $Width,
[Parameter(Mandatory = $false)]
[int] $PaddingLeft,
[Parameter(Mandatory = $false)]
[int] $PaddingRight
)
$PSBoundParameters.Add("Type", "Error")
Show-Message @PSBoundParameters
}
function Show-Choice
{
<#
.SYNOPSIS
Shows choices.
.DESCRIPTION
Shows choices to the console and returns the answer.
.PARAMETER Choice
A string array containing the possible choices.
.PARAMETER Prompt
A string containing the prompt to show.
.PARAMETER Help
A string containing a help message.
.PARAMETER Default
An integer containing the index of the default choice.
.PARAMETER Width
An integer specifying the width of the message.
.PARAMETER PaddingLeft
An integer specifying the left padding of the message.
.PARAMETER PaddingRight
An integer specifying the right padding of the message.
.OUTPUTS
System.Int32
Returns an integer containing the index of the choice selected.
.EXAMPLE
Show-Choice -Choice @( "Yes", "No" )
Description
-----------
This example will show the choices and returns the choice selected.
.EXAMPLE
Show-Choice -Choice @( "Yes", "No" ) -Default 0 -Prompt "Your answer"
Description
-----------
This example will show the choices with default being "Yes" and prompt "Your answer", and returns the choice selected.
.NOTES
.LINK
Show-Message
.LINK
Show-Question
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string[]] $Choice,
[Parameter(Mandatory = $false)]
[string] $Prompt,
[Parameter(Mandatory = $false)]
[int] $Default = -1,
[Parameter(Mandatory = $false)]
[string] $Help = "",
[Parameter(Mandatory = $false)]
[int] $Width,
[Parameter(Mandatory = $false)]
[int] $PaddingLeft,
[Parameter(Mandatory = $false)]
[int] $PaddingRight
)
$PSBoundParameters.Add("Message", " ")
$PSBoundParameters.Add("TextColor", $Host.UI.RawUI.ForegroundColor)
$PSBoundParameters.Add("PrimaryColor", $Host.UI.RawUI.BackgroundColor)
$PSBoundParameters.Add("SecondaryColor", $Host.UI.RawUI.BackgroundColor)
$PSBoundParameters.Remove("Choice") | Out-Null
$PSBoundParameters.Remove("Prompt") | Out-Null
$PSBoundParameters.Remove("Default") | Out-Null
$PSBoundParameters.Remove("Help") | Out-Null
$Answer = " "
$i = 1
$Choice | ForEach-Object {
$PSBoundParameters.Message = "[{0}] {1}" -f $i.ToString(("").PadLeft($Choice.Count.ToString().Length , "0")), $_
if (($i - 1) -eq $Default) { $PSBoundParameters.TextColor = [System.ConsoleColor]::Yellow }
else { $PSBoundParameters.TextColor = $Host.UI.RawUI.ForegroundColor }
Show-Message @PSBoundParameters
$i++
}
if ($Help)
{
$PSBoundParameters.Message = "[{0}] {1}" -f "?", $script:LocalizedData.Choice.Help
$PSBoundParameters.TextColor = [System.ConsoleColor]::Cyan
Show-Message @PSBoundParameters
}
Write-Host " "
while (($Answer -eq "?") -or ($Answer -notmatch "^[\d\.]+$") -or (($Answer -as [int]) -lt 1) -or (($Answer -as [int]) -gt ($Choice.Count)))
{
if (!$Prompt) { $Prompt = $script:LocalizedData.Choice.YourAnswer }
# $DisplayPrompt = Format-String -String $Prompt -Widt $Width -PaddingLeft $PaddingLeft -PaddingRight $PaddingRight
$DisplayPrompt = $Prompt
if ($Default -ge 0) { $DisplayPrompt += " " + ($script:LocalizedData.Choice.Default -f ($Default + 1)) }
$Answer = Read-Host -Prompt (Format-String -String $DisplayPrompt -Widt $Width -PaddingLeft $PaddingLeft -PaddingRight $PaddingRight)
if (!$Answer -and ($Default -ge 0)) { $Answer = $Default + 1 }
if (($Answer -eq "?") -and $Help)
{
Show-Information -Message $Help -Widt $Width -PaddingLeft $PaddingLeft -PaddingRight $PaddingRight
$Answer = ""
}
}
return ($Answer - 1)
}
function Format-String
{
<#
.SYNOPSIS
Formats a string.
.DESCRIPTION
Formats a string.
.PARAMETER String
A string containing the string to format.
.PARAMETER Width
An integer specifying the width to fit to.
.PARAMETER Align
A string containing the alignment of the text.
.PARAMETER PaddingLeft
An integer specifying the left padding of the string.
.PARAMETER PaddingRight
An integer specifying the right padding of the string.
.INPUTS
System.String
You can pipe a value for the string to this cmdlet.
.OUTPUTS
System.String
Returns a String containing the formated string.
.NOTES
.LINK
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[string] $String,
[Parameter(Mandatory = $false)]
[int] $Width = $Host.UI.RawUI.MaxWindowSize.Width - $Host.UI.RawUI.CursorPosition.X,
[Parameter(Mandatory = $false)]
[ValidateSet("Center", "Left", "Right")]
[string] $Align = "Left",
[Parameter(Mandatory = $false)]
[int] $PaddingLeft,
[Parameter(Mandatory = $false)]
[int] $PaddingRight
)
$String = "{0}{1}{2}" -f ("").PadLeft($PaddingLeft, " "), $String, ("").PadRight($PaddingRight, " ")
switch ($Align)
{
"Center"
{
[int32] $Padding = ($Width - $String.Length) / 2
$FullLength = $String.Length + $Padding * 2
if ($FullLength -lt $Width) { $String = "{0}{1}{2}" -f ("").PadLeft($Padding, " "), $String, ("").PadRight($Padding + 1, " ") }
elseif ($FullLength -eq $Width) { $String = "{0}{1}{2}" -f ("").PadLeft($Padding, " "), $String, ("").PadRight($Padding, " ") }
else { $String = "{0}{1}{2}" -f ("").PadLeft($Padding, " "), $String, ("").PadRight($Padding - 1, " ") }
}
"Left" { $String = $String }
"Right"
{
$String = "{0}{1}" -f ("").PadLeft($Width - $String.Length, " "), $String
}
}
return $String
}
@{
Module = @{
Describe = "Module"
ImportModule = "Importation locale du module."
CommandCheck = "Vérification du nombre de fonctions exportées."
}
Message = @{
Describe = "Show-Messages"
Tests = "Test des messages"
}
Question = @{
Describe = "Show-Question"
QuestionChoice = "Question avec choix"
QuestionDefaultChoice = "Question avec choix par défaut"
QuestionNoChoice = "Question sans choix"
}
ConvertTest = @{
DescribeConvert = "ConvertTo-Color"
DescribeTest = "Test-Color"
Color = "Depuis ConsoleColor"
String = "Depuis String"
Hex = "Depuis Hexadecimal"
Hex2 = "Depuis Hexadecimal sans « # »"
Hash = "Depuis Hashtable"
Object = "Depuis Object"
IntArray = "Depuis Int array"
StringArray = "Depuis String array"
Float = "Depuis Float"
}
Format = @{
Describe = "Format-String"
Left = "Alignement gauche"
Right = "Alignement droite"
Center = "Alignement centre"
CenterPadding = "Alignement centre avec padding"
}
}
@{
Global = @{
Debug = @{
Entering = "Début de la fonction « {0} »"
Leaving = "Fin de la fonction « {0} »"
}
}
ImportModule = @{
Error = @{
ImportError = @{
Message = "Impossible d'importer la fonction « {0} » : {1}"
Target = "Fonction"
}
}
}
Choice = @{
YourAnswer = "Votre réponse"
Default = "(le défaut est « {0} »)"
Help = "Aide"
TypeHelp = "(entrer ""{0}"" pour l'aide)"
}
}
@{
Module = @{
Describe = "Module"
ImportModule = "Importing module locally."
CommandCheck = "Checking exported commands count."
}
Message = @{
Describe = "Show-Messages"
Tests = "Testing messages"
}
Question = @{
Describe = "Show-Question"
QuestionChoice = "Question with choices"
QuestionDefaultChoice = "Question with default choice"
QuestionNoChoice = "Question without choice"
}
ConvertTest = @{
DescribeConvert = "ConvertTo-Color"
DescribeTest = "Test-Color"
Color = "From ConsoleColor"
String = "From String"
Hex = "From Hexadecimal code"
Hex2 = "From Hexadecimal code without '#'"
Hash = "From Hashtable"
Object = "From Object"
IntArray = "From Int array"
StringArray = "From String array"
Float = "From Float"
}
Format = @{
Describe = "Format-String"
Left = "Align left"
Right = "Align right"
Center = "Align center"
CenterPadding = "Align center with padding"
}
}
@{
Global = @{
Debug = @{
Entering = "Entering '{0}'"
Leaving = "Leaving '{0}'"
}
}
ImportModule = @{
Error = @{
ImportError = @{
Message = "Failed to import function '{0}': {1}"
Target = "Function"
}
}
}
Choice = @{
YourAnswer = "Your answer"
Default = "(default is ""{0}"")"
Help = "Help"
TypeHelp = "(type ""{0}"" for help)"
}
}
function Show-Warning
{
<#
.SYNOPSIS
Shows a warning message.
.DESCRIPTION
Shows a warning message to the console.
.PARAMETER Message
A string containing the message to show.
.PARAMETER Width
An integer specifying the width of the message.
.PARAMETER PaddingLeft
An integer specifying the left padding of the message.
.PARAMETER PaddingRight
An integer specifying the right padding of the message.
.EXAMPLE
Show-Warning -Message "This is a warning"
Description
-----------
This example will show the warning "This is a warning".
.NOTES
.LINK
Show-Message
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Message,
[Parameter(Mandatory = $false)]
[int] $Width,
[Parameter(Mandatory = $false)]
[int] $PaddingLeft,
[Parameter(Mandatory = $false)]
[int] $PaddingRight
)
$PSBoundParameters.Add("Type", "Warning")
Show-Message @PSBoundParameters
}
function Show-Unspecified
{
<#
.SYNOPSIS
Shows an unspecified message.
.DESCRIPTION
Shows an unspecified to the console.
.PARAMETER Message
A string containing the message to show.
.PARAMETER Width
An integer specifying the width of the message.
.PARAMETER PaddingLeft
An integer specifying the left padding of the message.
.PARAMETER PaddingRight
An integer specifying the right padding of the message.
.EXAMPLE
Show-Unspecified -Message "This is an unknown status"
Description
-----------
This example will show the information "This is an unknown status".
.NOTES
.LINK
Show-Message
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Message,
[Parameter(Mandatory = $false)]
[int] $Width,
[Parameter(Mandatory = $false)]
[int] $PaddingLeft,
[Parameter(Mandatory = $false)]
[int] $PaddingRight
)
$PSBoundParameters.Add("Type", "Unspecified")
Show-Message @PSBoundParameters
}
function Show-Success
{
<#
.SYNOPSIS
Shows a success message.
.DESCRIPTION
Shows a success message to the console.
.PARAMETER Message
A string containing the message to show.
.PARAMETER Width
An integer specifying the width of the message.
.PARAMETER PaddingLeft
An integer specifying the left padding of the message.
.PARAMETER PaddingRight
An integer specifying the right padding of the message.
.EXAMPLE
Show-Success -Message "Completed successfully"
Description
-----------
This example will show the success "Completed successfully".
.NOTES
.LINK
Show-Message
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Message,
[Parameter(Mandatory = $false)]
[int] $Width,
[Parameter(Mandatory = $false)]
[int] $PaddingLeft,
[Parameter(Mandatory = $false)]
[int] $PaddingRight
)
$PSBoundParameters.Add("Type", "Success")
Show-Message @PSBoundParameters
}
function Show-Information
{
<#
.SYNOPSIS
Shows an information message.
.DESCRIPTION
Shows an information to the console.
.PARAMETER Message
A string containing the message to show.
.PARAMETER Width
An integer specifying the width of the message.
.PARAMETER PaddingLeft
An integer specifying the left padding of the message.
.PARAMETER PaddingRight
An integer specifying the right padding of the message.
.EXAMPLE
Show-Information -Message "This is an information"
Description
-----------
This example will show the information "This is an information".
.NOTES
.LINK
Show-Message
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Message,
[Parameter(Mandatory = $false)]
[int] $Width,
[Parameter(Mandatory = $false)]
[int] $PaddingLeft,
[Parameter(Mandatory = $false)]
[int] $PaddingRight
)
$PSBoundParameters.Add("Type", "Information")
Show-Message @PSBoundParameters
}
function ConvertTo-Color
{
<#
.SYNOPSIS
Converts to a color.
.DESCRIPTION
Converts to a color.
.PARAMETER Color
An object representing the color.
This can be
- a ConsoleColor,
- a String with the name of the ConsoleColor,
- a String containing the hexadecimal color (with or without '#'),
- an Hashtable or PSCustomObject containing R, G and B members,
- an Integer array containing the values for R, G and B (in this order).
.INPUTS
System.Management.Automation.PSCustomObject
You can pipe a value for the color to this cmdlet.
.INPUTS
System.ConsoleColor
You can pipe a value for the color to this cmdlet.
.INPUTS
System.Hashtable
You can pipe a value for the color to this cmdlet.
.INPUTS
System.String
You can pipe a value for the color to this cmdlet.
.EXAMPLE
ConvertTo-Color -Color "Red"
Description
-----------
This example will test the color with value "Red".
.NOTES
Arrays can not be piped to this function as they will be unwraped.
.LINK
Test-Color
#>
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
$Color
)
switch -Regex ($Color.GetType().Name)
{
"ConsoleColor" { $Color }
"Hashtable|PSCustomObject"
{
if ((Test-Color -Color $Color)) { $Color }
else { Write-Error -Message "Color must contain R, G and B values between 0 and 255." -Category InvalidData -CategoryActivity $MyInvocation.MyCommand -TargetType "Color" -TargetName $Color.GetType().Name -Exception InvalidDataException }
}
"Object\[\]"
{
$ColorMap = @{
R = $Color[0];
G = $Color[1];
B = $Color[2];
}
if ((Test-Color -Color $ColorMap)) { $ColorMap }
else { Write-Error -Message "Color must contain R, G and B values between 0 and 255." -Category InvalidData -CategoryActivity $MyInvocation.MyCommand -TargetType "Color" -TargetName $Color.GetType().Name -Exception InvalidDataException }
}
"String"
{
if ($Color.StartsWith("#")) { $Color = $Color.Substring(1) }
if ($Color -match '[A-Fa-f0-9]{6}')
{
$ColorMap = @{
R = [convert]::ToInt32($Color.Substring(0, 2), 16);
G = [convert]::ToInt32($Color.Substring(2, 2), 16);
B = [convert]::ToInt32($Color.Substring(4, 2), 16)
}
if ((Test-Color -Color $ColorMap)) { $ColorMap }
else { Write-Error -Message "Hex color '$Color' is not valide." -Category InvalidData -CategoryActivity $MyInvocation.MyCommand -TargetType "Color" -TargetName $Color.GetType().Name -Exception InvalidDataException }
}
else
{
try
{
[System.ConsoleColor] $Color = $Color
$Color
}
catch { Write-Error $_ }
}
}
default { Write-Error -Message "Color type '$($Color.GetType().Name)' is not valid." -Category InvalidArgument -CategoryActivity $MyInvocation.MyCommand -TargetType "Color" -TargetName $Color.GetType().Name -Exception InvalidArgumentException }
}
}
Log in or click on link to see number of positives.
- bca-text.0.1.0.nupkg (0b90e716e785) - ## / 64
In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).
Chocolatey Pro provides runtime protection from possible malware.
(c) 2020 Bca. All rights reserved.
0.1.0:
- First version supports:
- Show message, information, success, warning, error, question (with or without choices, supporting default choice and help) and unspecified;
- Format string (left, right and center align);
- Split string on multiple lines;
- Convert and test colors;
- Write on host using custom colors (as opposed to only supporting ConsoleColor).
This package has no dependencies.
Ground Rules:
- This discussion is only about Bca.Text and the Bca.Text package. If you have feedback for Chocolatey, please contact the Google Group.
- This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
- The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
- Tell us what you love about the package or Bca.Text, or tell us what needs improvement.
- Share your experiences with the package, or extra configuration or gotchas that you've found.
- If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
bca (maintainer) on 25 Sep 2020 15:46:31 +00:00:
User 'bca' (maintainer) submitted package.
chocolatey-ops (reviewer) on 25 Sep 2020 16:18:43 +00:00:
bca-text has passed automated validation. It may have or may still fail other checks like testing (verification).
Congratulations! This package passed automatic validation review without flagging on any issues the validator currently checks. A human review could still turn up issues a computer may not easily find.
chocolatey-ops (reviewer) on 25 Sep 2020 22:00:26 +00:00:
bca-text has passed automated testing.
This is not the only check that is performed so check the package page to ensure a 'Ready' status.
Please visit https://gist.github.com/3085873bfa7e524410a7605828015a45 for details.
This is an FYI only. There is no action you need to take.
flcdrg (reviewer) on 26 Sep 2020 22:16:04 +00:00:
Please resolve these to allow this package to be approved:
tools\VERIFICATION.txt
andtools\LICENSE.txt
. Seechoco new
for examples.thanks,
David
bca (maintainer) on 27 Sep 2020 13:40:28 +00:00:
Hi,
Aren't the LICENSE.txt and VERIFICATION.txt for when the package includes binary files?
This package only includes PowerShell files, as do my other packages, and I didn't have to add LICENSE.txt and VERIFICATION.tx files.
Thanks
flcdrg (reviewer) on 28 Sep 2020 08:30:44 +00:00:
Good question. I went back and checked with the other moderators and the consensus is that any time a package maintainer includes files in addition to the standard Chocolatey files (eg. nuspec, chocolateyInstall.ps1 etc), then we really should have a LICENCE.txt and VERIFICATION.txt.
The majority of these files tend to be binaries (as you say), but to be consistent it doesn't really matter if a file is binary or text - we want to have a way for the end user to independently validate that the files are unmodified, and that it is permitted for those files to be redistributed (via the text in the license file) inside a Chocolatey package.
I think the fact that your other packages didn't have this was an oversight from the other moderators,
David
bca (maintainer) on 28 Sep 2020 12:51:38 +00:00:
The only thing I could find about this file is for binaries on this page (point 10) and it doesn't really explain what it should contain.
From what I see in other PowerShell packages, such as this one or this one, it's basically a procedure explaining how to compare the files checksums between the ones in the package and the one in the project source, am I correct?
Thanks
bca (maintainer) on 28 Sep 2020 17:40:48 +00:00:
User 'bca' (maintainer) submitted package.
chocolatey-ops (reviewer) on 28 Sep 2020 18:12:52 +00:00:
bca-text has passed automated validation. It may have or may still fail other checks like testing (verification).
Congratulations! This package passed automatic validation review without flagging on any issues the validator currently checks. A human review could still turn up issues a computer may not easily find.
chocolatey-ops (reviewer) on 29 Sep 2020 00:23:19 +00:00:
bca-text has passed automated testing.
This is not the only check that is performed so check the package page to ensure a 'Ready' status.
Please visit https://gist.github.com/adb709484b885359e8f22f44345098a6 for details.
This is an FYI only. There is no action you need to take.
flcdrg (reviewer) on 09 Oct 2020 10:25:18 +00:00:
Yep. So confirmed with other moderators. Any time any kind of software is bundled inside the package, VERIFICATION.txt and LICENSE.txt need to be included
David
bca (maintainer) on 13 Oct 2020 18:45:06 +00:00:
User 'bca' (maintainer) submitted package.
chocolatey-ops (reviewer) on 13 Oct 2020 19:20:03 +00:00:
bca-text has passed automated validation. It may have or may still fail other checks like testing (verification).
Congratulations! This package passed automatic validation review without flagging on any issues the validator currently checks. A human review could still turn up issues a computer may not easily find.
chocolatey-ops (reviewer) on 14 Oct 2020 23:51:27 +00:00:
bca-text has passed automated testing.
This is not the only check that is performed so check the package page to ensure a 'Ready' status.
Please visit https://gist.github.com/a0d16346868748e45bf47aec9555b52b for details.
This is an FYI only. There is no action you need to take.
mkevenaar (reviewer) on 10 Nov 2020 08:12:45 +00:00:
Hi,
the license and verification text files are still missing in the package. Could you please fix that?
when I wanted to look at the Package Source, I noticed that the packageSourceUrl is not pointing to the source of the package (could be different from the Software Source) This URL should point to a repository or repository folder where the files like chocolateyInstall.ps1 and your nuspec file are located.
chocolatey-ops (reviewer) on 30 Nov 2020 08:12:54 +00:00:
We've found bca-text v0.1.0 in a submitted status and waiting for your next actions. It has had no updates for 20 or more days since a reviewer has asked for corrections. Please note that if there is no response or fix of the package within 15 days of this message, this package version will automatically be closed (rejected) due to being stale.
Take action:
If your package is failing automated testing, you can use the chocolatey test environment to manually run the verification and determine what may need to be fixed.
Note: We don't like to see packages automatically rejected. It doesn't mean that we don't value your contributions, just that we can not continue to hold packages versions in a waiting status that have possibly been abandoned. If you don't believe you will be able to fix up this version of the package within 15 days, we strongly urge you to log in to the site and respond to the review comments until you are able to.
chocolatey-ops (reviewer) on 15 Dec 2020 08:16:59 +00:00:
Unfortunately there has not been progress to move bca-text v0.1.0 towards an approved status within 15 days after the last review message, so we need to close (reject) the package version at this time. If you want to pick this version up and move it towards approval in the future, use the contact site admins link on the package page and we can move it back into a submitted status so you can submit updates.
Status Change - Changed status of package from 'submitted' to 'rejected'.