Skip to content

skint007Labs/PSSharprompt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSSharprompt

GitHub version Static Badge

About

This is a simple wrapper for the great Sharprompt library to make it easier to use in PowerShell.

Note

This module is now compatible with PowerShell 5.1 and above.

This is still a work in progress and not all features are supported yet.

Installation

Install the module from the PowerShell Gallery

Install-Module -Name PSSharprompt

You can also install the module from the GitHub repository by downloading the latest release.

Note

You will need to include the Sharprompt.dll in the same directory as the module dll.*

Import-Module .\PSSharprompt.dll

Supported Features from Sharprompt

Basic Input

  • Show-PromptInput
  • Show-PromptPassword
  • Show-PromptConfirm
  • Show-PromptSelect
  • Show-PromptMultiSelect

Schema settings

  • Set-PromptColorSchema
  • Set-PromptSymbol

Validation Support

The following functions support validation:

  • Show-PromptInput
  • Show-PromptList
  • Show-PromptPassword

You can use the following parameters to validate the input:

[switch] -Required
   [int] -MinLength
   [int] -MaxLength
[string] -RegularExpression

When not supplied, they have the same defaults as Sharprompt.

Examples

Make sure to import the module first

Import-Module PSSharprompt

Show-PromptInput

$Name = Show-PromptInput -Message 'What is your name?' -Default 'John Doe'
"Hello, $Name!"

Show-PromptPassword

$Password = Show-PromptPassword -Message 'Enter your password'
"Your password is valid!"
$Password = Show-PromptPassword -Message 'Enter your password' -Required -MinLength 8 -MaxLength 16 -RegularExpression '^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&\._\-\(\)]+$'
"Your password is valid!"

Show-PromptConfirm

$Confirm = Show-PromptConfirm -Message 'Are you sure?' -Default $false
"They said: $Confirm"

Show-PromptSelect

$Selected = Show-PromptSelect -Message 'Select your favorite color' -Items 'Red', 'Green', 'Blue'
$Selected

Show-PromptMultiSelect

$Selected = Show-PromptMultiSelect -Message 'Select your favorite colors' -Items 'Red', 'Green', 'Blue'
$Selected -join ', '

About

A PowerShell Wrapper for Sharprompt

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages