-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to better way of doing completions from trackd
- Loading branch information
1 parent
b392af2
commit e7a98cf
Showing
22 changed files
with
137 additions
and
107 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
{ | ||
"powershell.codeFormatting.preset": "OTBS" | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using module ".\attributes\ColorAttributes.psm1" | ||
using module ".\completions\Completers.psm1" | ||
|
||
<# | ||
.SYNOPSIS | ||
|
20 changes: 0 additions & 20 deletions
20
PwshSpectreConsole/private/attributes/BorderAttributes.psm1
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
PwshSpectreConsole/private/attributes/ColorAttributes.psm1
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
PwshSpectreConsole/private/attributes/SpinnerAttributes.psm1
This file was deleted.
Oops, something went wrong.
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 @@ | ||
using namespace Spectre.Console | ||
using namespace System.Management.Automation | ||
|
||
class ValidateSpectreColor : ValidateArgumentsAttribute { | ||
ValidateSpectreColor() : base() { } | ||
[void]Validate([object] $Color, [EngineIntrinsics]$EngineIntrinsics) { | ||
# Handle hex colors | ||
if ($Color -match '^#[A-Fa-f0-9]{6}$') { | ||
return | ||
} | ||
$spectreColors = [Color] | Get-Member -Static -Type Properties | Select-Object -ExpandProperty Name | ||
$result = $spectreColors -contains $Color | ||
if ($result -eq $false) { | ||
throw "'$Color' is not in the list of valid Spectre colors ['$($spectreColors -join ''', ''')']" | ||
} | ||
} | ||
} | ||
|
||
class ArgumentCompletionsSpectreColors : ArgumentCompleterAttribute { | ||
ArgumentCompletionsSpectreColors() : base({ | ||
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) | ||
$options = [Color] | Get-Member -Static -Type Properties | Select-Object -ExpandProperty Name | ||
return $options | Where-Object { $_ -like "$wordToComplete*" } | ||
}) { } | ||
} | ||
|
||
class SpectreConsoleTableBorder : IValidateSetValuesGenerator { | ||
[String[]] GetValidValues() { | ||
$lookup = [TableBorder] | Get-Member -Static -MemberType Properties | Select-Object -ExpandProperty Name | ||
return $lookup | ||
} | ||
} | ||
|
||
class SpectreConsoleBoxBorder : IValidateSetValuesGenerator { | ||
[String[]] GetValidValues() { | ||
$lookup = [BoxBorder] | Get-Member -Static -MemberType Properties | Select-Object -ExpandProperty Name | ||
return $lookup | ||
} | ||
} | ||
|
||
class SpectreConsoleJustify : IValidateSetValuesGenerator { | ||
[String[]] GetValidValues() { | ||
$lookup = [Justify].GetEnumNames() | ||
return $lookup | ||
} | ||
} | ||
|
||
class SpectreConsoleSpinner : IValidateSetValuesGenerator { | ||
[String[]] GetValidValues() { | ||
$lookup = [Spinner+Known] | Get-Member -Static -MemberType Properties | Select-Object -ExpandProperty Name | ||
return $lookup | ||
} | ||
} | ||
|
||
class SpectreConsoleTreeGuide : IValidateSetValuesGenerator { | ||
[String[]] GetValidValues() { | ||
$lookup = [TreeGuide] | Get-Member -Static -MemberType Properties | Select-Object -ExpandProperty Name | ||
return $lookup | ||
} | ||
} |
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,44 @@ | ||
function Get-SpectreColorDemo { | ||
[Reflection.AssemblyMetadata("title", "Start-SpectreDemo")] | ||
param () | ||
|
||
$colors = [Spectre.Console.Color] | Get-Member -Static -Type Properties | Select-Object -ExpandProperty Name | ||
$colors = $colors | ForEach-Object { | ||
$prefix = ($_ -replace '[_0-9]+', '') | ||
$numeric = ($_ -replace '^[^0-9]+', '') | ||
$value = 0 | ||
if([string]::IsNullOrEmpty($numeric)) { | ||
$value = 0.0 | ||
} else { | ||
$numericParts = $numeric.Split('_') | ||
if($numericParts.Count -lt 2) { | ||
$value = [double]"$($numericParts[0]).9" | ||
} else { | ||
$value = [double]"$($numericParts[0]).$($numericParts[1])" | ||
} | ||
} | ||
return [pscustomobject]@{ | ||
Name = $_ | ||
Prefix = $prefix | ||
Numeric = $value | ||
} | ||
} | Sort-Object -Property @{Expression = "Prefix"}, @{Expression = "Numeric"} | Select-Object -ExpandProperty Name | ||
|
||
$maxLength = $colors | Measure-Object -Maximum -Property Length | Select-Object -ExpandProperty Maximum | ||
|
||
foreach($color in $colors) { | ||
$total = [Spectre.Console.Color]::$color | Select-Object @{ Name = "Total"; Expression = {$_.R + $_.G + $_.B} } | Select-Object -ExpandProperty Total | ||
$textColor = "white" | ||
if($total -gt 280) { | ||
$textColor = "black" | ||
} | ||
|
||
Write-SpectreHost -NoNewline "[$textColor on $color] $($color.PadRight($maxLength)) [/] " | ||
Write-SpectreHost ("[$color]$color[/]") | ||
} | ||
|
||
Write-Host "`nThe colors can be passed as the -Color parameter for most commands or used in Spectre Console markup like so:`n" | ||
Write-Host " Input: I am [Red]colored text[/] using [Yellow1 on Turquoise4]Spectre markdown[/]!" | ||
Write-SpectreHost " Output: I am [Red]colored text[/] using [Yellow1 on Turquoise4]Spectre markdown[/]!" | ||
Write-SpectreHost "`nFor more markdown hints see [link]https://spectreconsole.net/markup[/]`n" | ||
} |
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
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
2 changes: 1 addition & 1 deletion
2
PwshSpectreConsole/public/prompts/Read-SpectreMultiSelection.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
2 changes: 1 addition & 1 deletion
2
PwshSpectreConsole/public/prompts/Read-SpectreMultiSelectionGrouped.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
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