-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from StartAutomating/Irregular-Updates
Irregular 0.7.8
- Loading branch information
Showing
73 changed files
with
696 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
function Compress-Regex | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Compresses Regular Expressions | ||
.DESCRIPTION | ||
Compresses a Regular Expression, removing all whitespace and comments. | ||
This will make a regular expression much more difficult to read, and a bit shorter. | ||
.EXAMPLE | ||
New-Regex -Description "This is a description of a regex nobody will care about" | | ||
New-Regex -Name Width @( | ||
?<Decimals> | ||
) | | ||
New-Regex -Name Height @( | ||
?<Decimals> | ||
) | Compress-Regex | ||
#> | ||
param( | ||
# The regular expression to compress. | ||
[Parameter(Mandatory, | ||
ValueFromPipeline, | ||
ValueFromPipelineByPropertyName, | ||
Position=0)] | ||
[Alias('RegularExpression','Pattern','Expression')] | ||
[Regex] | ||
$Regex, | ||
|
||
# The Match Timeout. | ||
# By default, this value will be carried over from the -RegEx. | ||
[timespan] | ||
$MatchTimeout = '00:00:01' | ||
) | ||
|
||
process { | ||
# Create a new regex from the old: | ||
[Regex]::new( | ||
( | ||
# To compress the regex, split it by newlines | ||
"$Regex" -split '(?>\r\n|\n)' -replace | ||
# and strip comments | ||
'(?<!\\)#.+$' -join ([Environment]::NewLine) -replace | ||
# and strip whitespace. | ||
'[\s\n\r]' | ||
), | ||
# We'll keep the regex options should remain the same, for now. | ||
$Regex.Options, | ||
$( | ||
# If we provided a -MatchTimeout | ||
if ($PSBoundParameters["MatchTimeout"]) { | ||
$MatchTimeout # use that | ||
} elseif ($Regex.MatchTimeout.TotalSeconds -gt 0) { | ||
$Regex.MatchTimeout # otherwise, carry the timeout from the [Regex] | ||
} else { | ||
$MatchTimeout # and if it didn't have one, use the default for -MatchTimeout. | ||
} | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
describe 'Irregular Console Patterns' { | ||
it 'Can match any Escape sequence' { | ||
"$([char]0x1b)[0m" | ?<Console_Code> | Select-Object -ExpandProperty Length | Should -be 4 | ||
|
||
"$([char]0x1b)[1;3;5,~" | ?<Console_Code> | Select-Object -ExpandProperty Length | Should -be 9 | ||
} | ||
context 'Console Colors' { | ||
it 'Can Match a 4-bit color' { | ||
$x = "$([char]0x1b)[32m" | ?<Console_4BitColor> -Extract | ||
$x.ColorNumber | Should -Be 2 | ||
$x.IsForegroundColor | Should -Be 3 | ||
} | ||
|
||
it 'Can Match a 24-bit color' { | ||
$x = "$([char]0x1b)[38;2;255;100;0m" | ?<Console_24BitColor> -Extract | ||
$x.Red | Should -be 255 | ||
$x.Green | Should -be 100 | ||
$x.Blue | Should -be 0 | ||
} | ||
} | ||
|
||
context 'Console Styles' { | ||
it 'Can Match Console Styles' { | ||
@("$([char]0x1b)[3m Italics $([char]0x1b)[23m" | ?<Console_Style>).Count | Should -be 2 | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
This directory contains regular expressions for advanced console features, such as [ANSI escape sequences](https://en.wikipedia.org/wiki/ANSI_escape_code). | ||
|
||
Note: Using these regular expressions in the terminal may result in awkward output. (the .Match will contain an escape sequence, which will make the next output attempt to use this escape sequence) | ||
|
||
|
||
|Name |Description |Source | | ||
|---------------------------------------------------|-------------------------------------------------------------|----------------------------------------| | ||
|[?<Console_24BitColor>](24BitColor.regex.txt) |Matches an ANSI 24-bit color |[source](24BitColor.regex.source.ps1) | | ||
|[?<Console_4BitColor>](4BitColor.regex.txt) |Matches an ANSI 3 or 4-bit color |[source](4BitColor.regex.source.ps1) | | ||
|[?<Console_8BitColor>](8BitColor.regex.txt) |Matches an ANSI 8-bit color |[source](8BitColor.regex.source.ps1) | | ||
|[?<Console_Blink>](Blink.regex.txt) |Matches ANSI Blink Start or End |[source](Blink.regex.source.ps1) | | ||
|[?<Console_Bold>](Bold.regex.txt) |Matches an ANSI Bold (aka bright) Start or End |[source](Bold.regex.source.ps1) | | ||
|[?<Console_Code>](Code.regex.txt) |Matches an ANSI escape code |[source](Code.regex.source.ps1) | | ||
|[?<Console_Color>](Color.regex.txt) |Matches an ANSI color |[source](Color.regex.source.ps1) | | ||
|[?<Console_Cursor>](Cursor.regex.txt) |Matches an ANSI cursor control |[source](Cursor.regex.source.ps1) | | ||
|[?<Console_DefaultColor>](DefaultColor.regex.txt) |Matches an ANSI default color |[source](DefaultColor.regex.source.ps1) | | ||
|[?<Console_Faint>](Faint.regex.txt) |Matches an ANSI Faint (aka dim) Start or End |[source](Faint.regex.source.ps1) | | ||
|[?<Console_Hide>](Hide.regex.txt) |Matches ANSI Hide (aka conceal) Start or End |[source](Hide.regex.source.ps1) | | ||
|[?<Console_Invert>](Invert.regex.txt) |Matches ANSI Invert Start or End |[source](Invert.regex.source.ps1) | | ||
|[?<Console_Italic>](Italic.regex.txt) |Matches ANSI Italic Start or End |[source](Italic.regex.source.ps1) | | ||
|[?<Console_Link>](Link.regex.txt) |Matches ANSI Hyperlink |[source](Link.regex.source.ps1) | | ||
|[?<Console_Note>](Note.regex.txt) |Matches an ANSI VT520 Note |[source](Note.regex.source.ps1) | | ||
|[?<Console_Reset>](Reset.regex.txt) |Matches an ANSI Reset (this clears formatting) |[source](Reset.regex.source.ps1) | | ||
|[?<Console_Strikethrough>](Strikethrough.regex.txt)|Matches ANSI Strikethrough (aka crossed out) Start or End |[source](Strikethrough.regex.source.ps1)| | ||
|[?<Console_Style>](Style.regex.txt) |Matches an ANSI style (color or text option) |[source](Style.regex.source.ps1) | | ||
|[?<Console_Underline>](Underline.regex.txt) |Matches ANSI Underline/DoubleUnderline Start or Underline End|[source](Underline.regex.source.ps1) | | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.