-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #23 from StartAutomating/Splatter-Action
Splatter 0.5.5
- Loading branch information
Showing
18 changed files
with
1,521 additions
and
151 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: [StartAutomating] |
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,77 @@ | ||
#region Splatter [ 0.5.5 ] : Simple Scripts to Supercharge Splatting (Install-Module Splatter, then Initialize-Splatter -Verb Get,Use,Find -Compress -Minify ) | ||
.([ScriptBlock]::Create(([IO.StreamReader]::new(( | ||
[IO.Compression.GZipStream]::new([IO.MemoryStream]::new( | ||
[Convert]::FromBase64String(' | ||
H4sIAAAAAAAAA+Uc205bSbKf8xVnERrjxD6TPOw+gKwlyQ6ZaEKCIDPzYCHkGJJ4A8bDsT1hCf++ | ||
dek6XX05FxvIrLSywHaf7urquld3tTfNjfmn2TW3ZmA24fMrc2bm5sjMzLkZwSdp/xS03ZiheQ7f | ||
J9BSmC3TISgd04M/3bdjuuYYvo3MFfxdQM+hOSi/4Vxn8HnL7MP3qTmlMZfQck3zzuHTAnr0YMwl | ||
zDOBlgl8msLTpwQZoR2Zd+aD+Tf0G8PzIbQew9iX0O8CXgy3t+a8v8GTc/q8B20I8QAwmMF3XPsU | ||
3pvwfGbx9Kn1Gp7NYMzcw71TsSZcj6MprqUwf9IsY/OZnu4R9mPo34VxZ8ADxO4G/n+E+frw+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OpmO5DX3sN8M3vetsRlNejXv3E/NH5Umvwy4dE/gn735vxAzrm5mqfe85n5Skb2TVVdvi07+e | ||
Tr4FGdGO3bjUXb4b9T3v6rF/fWyrE0MvxfWMLqpnfZvbSgyNu38XK3z6kHT8f5Q47pOy/3eloo7e | ||
0lSs9x3fX3oRozaym1rt97e4aZ49lDVO86/t3l3d7fa4ViGuUGC70v0L5YLvwLeRjVRNg6sMxf2r | ||
F+UeabqyMz7xSMcl9/+bC/rMwNW/ux1fppCsXmIoqfmbUoyJ+V/9ClMYdGwNf9O+i87DHaXv//ch | ||
pI6tZ73UU8v9FB98j9WsJ2koWl/m9hdEnpXnJZxJSXY0XjE7ahd5yv6HRJ6OIumoc0OtrX1+xZS9 | ||
+35zvRWLz2cel2c4Y7KlKAtxryP4j5n0IbRfUnaMN3Gl9TP1R/v4H8N36vHpIXH7FHCYAuRr24rU | ||
/Eq9jmz/npKTqv1ynWmmzq501Vmc9cgO+dxq6NRqHmr+mKg1MldltlPXG9dzSpZXpEKfEuIvFKH1 | ||
5V0g+Q0GtKnXpU10NadFuXv/S9kjrAAp1M6D/t2XtNaKlvEtbNROzvkyw7+gkylscjP24skJ6ZL+ | ||
zSp9j0BGDanncXmLwOEpT3yKt6mxwdkwtlyS7eyU1OgE/FgHlqbkOvAeuv6n4+2J9lSU4qyuYC2V | ||
ravatNDe3J+li/dS/gZtiOV/AdDBNlK4UQAA | ||
')), | ||
[IO.Compression.CompressionMode]'Decompress')), | ||
[Text.Encoding]::unicode)).ReadToEnd() | ||
)) | ||
#endregion Splatter [ 0.5.5 ] : Simple Scripts to Supercharge Splatting (Install-Module Splatter, then Initialize-Splatter -Verb Get,Use,Find -Compress -Minify ) |
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,17 @@ | ||
#region Splatter [ 0.5.5 ] : Simple Scripts to Supercharge Splatting (Install-Module Splatter, then Initialize-Splatter -Verb Get,Use,Find -Minify ) | ||
|
||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification="This Declares Variables for Other Scripts")] | ||
param() | ||
${?@}=${GetSplat}=${gSplat}={[Alias('?@','gSplat')]param([Parameter(Mandatory=$true,Position=0)][PSObject[]]$Command,[Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=1)][Alias('InputObject')][PSObject]$Splat,[switch]$Force)begin{if(-not ${script:_@p}){${script:_@p}=@{}};if(-not ${script:_@c}){${script:_@c}=@{}};if(-not ${script:_@mp}){${script:_@mp}=@{}};if(-not ${script:_@pp}){${script:_@pp}=@{}};$ValidateAttributes={param([Parameter(Mandatory)]$value,[Parameter(Mandatory)]$attributes)foreach($attr in $attributes){$_=$this=$value;if($attr-is[Management.Automation.ValidateScriptAttribute]){$result=. $attr.ScriptBlock;if($result-ne$true){$attr}}elseif($attr-is[Management.Automation.ValidatePatternAttribute]-and(-not [Regex]::new($attr.RegexPattern, $attr.Options, '00:00:05').IsMatch($value))){$attr}elseif($attr-is[Management.Automation.ValidateSetAttribute]-and$attr.ValidValues-notcontains$value){$attr}elseif($attr-is[Management.Automation.ValidateRangeAttribute]-and(($value-gt$attr.MaxRange)-or($value-lt$attr.MinRange))){$attr}}}}process{$ap,$ac,$amp=${script:_@p},${script:_@c},${script:_@mp};if($Splat-is[Collections.IDictionary]){$splat=[PSCustomObject]([Ordered]@{} + $Splat)};$in=$Splat;foreach($cmd in $Command){$rc=if($ac.$cmd){$ac.$cmd}elseif($cmd-is[string]){$fc=$ExecutionContext.SessionState.InvokeCommand.GetCommand($cmd,'Function,Cmdlet,ExternalScript,Alias');$fc=if($fc-is[Management.Automation.AliasInfo]){$fc.ResolvedCommand}else{$fc};$ac.$cmd=$fc;$fc}elseif($cmd-is[ScriptBlock]){$hc=$cmd.GetHashCode();$ExecutionContext.SessionState.PSVariable.Set("function:f$hc", $cmd);$c=$ExecutionContext.SessionState.InvokeCommand.GetCommand("f$hc",'Function');$ac.$cmd=$c;$c}elseif($cmd-is[Management.Automation.CommandInfo]){$ac.$cmd=$cmd;$cmd};if(-not $rc){continue};$cmd=$rc;$outSplat,$Invalid,$Unmapped,$paramMap,$Pipe,$NoPipe=foreach($_ in 1..6){[ordered]@{}};$params=[Collections.ArrayList]::new();$props=@($in.psobject.properties);$pc=$props.Count;if(-not ${script:_@pp}.$cmd){${script:_@pp}.$cmd=@(foreach($param in $cmd.Parameters.Values){foreach($attr in $param.Attributes){if($attr.ValueFromPipeline){$param}}})};$cmdMd=$cmd-as[Management.Automation.CommandMetaData];$problems=@(foreach($vfp in ${script:_@pp}.$cmd){if($in-is$vfp.ParameterType-or($vfp.ParameterType.IsArray-and$in-as$vfp.ParameterType)){$v=$in;$badAttributes=& $ValidateAttributes $v $vfp.Attributes;if($badAttributes){@{$vfp.Name=$badAttributes}};if(-not $badAttributes-or$Force){$null=$params.Add($vfp.Name);$pipe[$vfp.Name]=$v;$outSplat[$vfp.Name]=$v;$paramMap[$vfp.Name]=$vfp.Name;$pipelineParameterSets=@(foreach($attr in $vfp.Attributes){if($attr.ParameterSetName){$attr.ParameterSetName}})}}};:NextProperty foreach($prop in $props){$cp=$cmd.Parameters;$pn=$prop.Name;$pv=$prop.Value;if(-not $cp){continue};$param=$cp.$pn;if(-not $param){$k="${cmd}:$pn";$param=if($ap[$k]){$ap[$k]}else{foreach($p in $cp.Values){foreach($a in $p.Aliases){$ap["${cmd}:$a"]=$p};if($ap[$k]){$ap[$k];break}}}};if(-not $param){$pn;continue};$paramMap[$param.Name]=$pn;if($params-contains$param){continue};$pt=$param.ParameterType;$paramSets=@(foreach($attr in $param.Attributes){if($attr.ParameterSetName){$attr.ParameterSetName}});if($pipelineParameterSets){$ok=$false;foreach($cmdPs in $paramSets){$ok=$ok-bor($pipelineParameterSets-contains$cmdPs)};if(-not $ok-and-not $Force){continue}};$v=$pv-as$pt;if(-not $v-and($pt-eq[ScriptBlock]-or$pt-eq[ScriptBlock[]])){$sb=try{foreach($_ in $pv){[ScriptBlock]::Create($_)}}catch{$null};if($sb){$v=$sb}};if($null-ne$v){$nv=try{[PSVariable]::new("$pn", $v, 'Private',$param.Attributes)}catch{@{$pn=$_}};if($nv-is[PSVariable]-or$Force){$null=$params.Add($param);:CanItPipe do{foreach($attr in $param.Attributes){if($attr.ValueFromPipeline-or$attr.ValueFromPipelineByPropertyName-and((-not $pipelineParameterSets)-or($pipelineParameterSets-contains$attr.ParameterSetName))){$pipe[$prop.Name]=$v;break CanItPipe}};$NoPipe[$prop.Name]=$v}while($false);$outSplat[$prop.Name]=$v};if($nv-isnot[PSVariable]){$nv}}else{@{$pn = $param}}});$Mandatory=@{};foreach($param in $cmdMd.Parameters.Values){foreach($a in $param.Attributes){if(-not $a.Mandatory){continue};if($a-isnot[Management.Automation.ParameterAttribute]){continue};if(-not $Mandatory[$a.ParameterSetName]){$Mandatory[$a.ParameterSetName]=[Ordered]@{}};$mp=($paramMap.($param.Name));$Mandatory[$a.ParameterSetName].($param.Name)=if($mp){if($pipelineParameterName-contains$param.Name){$in}else{$outSplat.$mp}}}};$amp.$cmd=$Mandatory;$mandatory=$amp.$cmd;$missingMandatory=@{};foreach($m in $Mandatory.GetEnumerator()){$missingMandatory[$m.Key]=@(foreach($_ in $m.value.GetEnumerator()){if($null-eq$_.Value){$_.Key}})};$couldRun=if(-not $Mandatory.Count){$true}elseif($missingMandatory.'__AllParameterSets'){$false}else{foreach($_ in $missingMandatory.GetEnumerator()){if(-not $_.Value){$true;break}}};if(-not $couldRun-and-not $Force){continue};foreach($p in $problems){if($p-is[Hashtable]){$Invalid+=$p}else{$Unmapped[$p]=$in.$p}};if($Invalid.Count-eq0){$Invalid=$null};if($Unmapped.Count-eq0){$Unmapped=$null};$realCmd=if($cmd-is[Management.Automation.FunctionInfo]-and$cmd.Name.Contains($cmd.ScriptBlock.GetHashCode().ToString())){$cmd.ScriptBlock}else{$cmd};foreach($_ in ([Ordered]@{ | ||
Command = $realCmd | ||
CouldRun = $couldRun | ||
Invalid = $Invalid | ||
Missing = $missingMandatory | ||
PercentFit = $(if ($pc) {$outSplat.Count / $pc } else { 0}) | ||
Unmapped = $Unmapped | ||
PipelineParameter = $Pipe | ||
NonPipelineParameter = $NoPipe | ||
}).GetEnumerator()){$outSplat.psobject.properties.Add([Management.Automation.PSNoteProperty]::new($_.Key,$_.Value))};$outSplat}}} | ||
${.@}=${UseSplat}={[Alias('.@','uSplat')]param([Parameter(Position=0)][PSObject[]]$Command,[Parameter(Position=1,ValueFromRemainingArguments)][PSObject[]]$ArgumentList,[Parameter(ValueFromPipeline=$true)][PSObject[]]$Splat,[switch]$Force,[Alias('BestFit','BestFitFunction', 'BF','BFF')][switch]$Best,[Alias('Pipe')][switch]$Stream)begin{$pipelines=@{}}process{$WeTrustTheSplat=$false;if(-not $Command-and$splat.Length-eq1-and$splat[0]-is[Collections.IDictionary]-and$Splat[0].psobject.Properties['Command']){$Command=$Splat[0].psobject.Properties['Command'].Value;$WeTrustTheSplat=$true}elseif(-not $command-and$_-is[PSObject]-and$_.Command-and$_.Splat){$WeTrustTheSplat=$true;$splat=$_.Splat;$command=$_.Command};if($Best-and$command.Count){$command=$splat|& ${?@} -Command $command|Sort-Object PercentFit -Descending|Select-Object -ExpandProperty Command -First 1};if(-not $Command){Write-Error -Message "No command found" -Category ObjectNotFound -ErrorId 'Use-Splat.CommandNotFound';return};foreach($cmd in $Command){if($WeTrustTheSplat){if($cmd-is[Management.Automation.CommandInfo]-or$cmd-is[ScriptBlock]){foreach($s in $splat){if($argumentList){& $cmd @s @ArgumentList}else{& $cmd @s}}}}else{$Splat|& ${?@} $cmd -Force:$Force|& {process{$i=$_;$np=$i.NonPipelineParameter;$c=$_.psobject.properties['Command'].Value;if($Stream){if(-not $pipelines[$c]){$stepScript=if($argumentList){{& $c @np @argumentList}}else{{& $c @np}};$stepPipeline=$stepScript.GetSteppablePipeline();$pipelines[$c]=$stepPipeline;$stepPipeline.Begin($true)}else{$stepPipeline=$pipelines[$c]};$stepPipeline.Process([PSCustomObject]$i.PipelineParameter);return};if($c-is[Management.Automation.CommandInfo]-or$c-is[ScriptBlock]){if($ArgumentList){& $c @i @ArgumentList}else{& $c @i}}}}}}}end{if($pipelines.Count){foreach($v in $pipelines.Values){$v.End()}}}} | ||
${??@}=${FindSplat}=${fSplat}={[Alias('??@','fSplat')]param([Parameter(Position=0)][string[]]$Command,[Parameter(ValueFromPipeline=$true,Position=1)][Alias('InputObject')][PSObject]$Splat,[Alias('G')][switch]$Global,[Alias('L')][switch]$Local,[Alias('M')][string[]]$Module,[switch]$Force)begin{$myModule=$MyInvocation.MyCommand.ScriptBlock.Module;$cmdTypes='Function,Cmdlet,ExternalScript,Alias';$resolveAliases={begin{$n=0}process{$n++;if($t-is[int]-and$id){$p=$n*100/$t;Write-Progress "Resolving" "$_ " -PercentComplete $p -Id $id};if($_.ResolvedCommand){$_.ResolvedCommand}else{$_}}end{Write-Progress 'Resolving Aliases' 'Complete' -Id $id}};$filterCmds={process{foreach($c in $Command){if($_-like$c){return $_}}}}}process{if(-not $Splat){return};$id=[Random]::new().Next();$commandList=@(if(-not $Command){Write-Progress -Id $id -Activity 'Getting Commands' -Status ' ';if($MyModule-and$Local){$myModule.ExportedCommands.Values|. $resolveAliases|Select-Object -Unique}elseif($module){foreach($m in $Module){$rm=Get-Module $m;if(-not $rm){continue};$rm.ExportedCommands.Values|. $resolveAliases|Select-Object -Unique}}else{$allcmds=@($ExecutionContext.SessionState.InvokeCommand.GetCommands('*',$cmdTypes, $true));$t=$allcmds.Count;$allcmds|. $resolveAliases|Select-Object -Unique}}elseif($module){foreach($m in $Module){$rm=Get-Module $m;if(-not $rm){continue};$rm.ExportedCommands.Values|. $resolveAliases|. $filterCmds|Select-Object -Unique}}elseif($Global){foreach($c in $Command){$ExecutionContext.SessionState.InvokeCommand.GetCommands($c,$cmdTypes, $true)}}elseif($MyModule-and$Local){$myModule.ExportedCommands.Values|. $filterCmds|. $resolveAliases|Select-Object -Unique}else{foreach($cmd in $Command){if($cmd-is[string]-and$cmd.Contains('*')){$ExecutionContext.SessionState.InvokeCommand.GetCommands($cmd,$cmdTypes, $true)}else{$cmd}}});$psBoundParameters.Command=$commandList;if($Splat-is[Collections.IDictionary]){$Splat=if($splat.GetType().Name-ne'PSBoundParametersDictionary'){[PSCustomObject]$Splat}else{[PSCustomObject]([Ordered]@{} + $Splat)}};$c,$t=0,$commandList.Count;foreach($cmd in $commandList){if($t-gt1){$c++;$p=$c*100/$t;Write-Progress -Id $id -Activity 'Finding Splats' -Status "$cmd " -PercentComplete $p};$Splat|& ${?@} $cmd -Force:$Force|Select-Object -Property * -ExcludeProperty SyncRoot,IsSynchronized,IsReadOnly,IsFixedSize,Count|& {process{if($_.PercentFit-eq0){return};$_.pstypenames.clear();$_.pstypenames.add('Find.Splat.Output');$keys, $values=$_.Keys,$_.Values;$resplat=[Ordered]@{};for($i=0;$i -lt $keys.count;$i++){$resplat[$keys[$i]]=$values[$i]};$_.psobject.properties.remove('Keys');$_.psobject.properties.remove('Values');$_.psobject.properties.Add([Management.Automation.PSNoteProperty]::new('Splat', $resplat));$_}}};Write-Progress -Id $id -Completed -Activity 'Finding Splats' -Status 'Complete!'}} | ||
#endregion Splatter [ 0.5.5 ] : Simple Scripts to Supercharge Splatting (Install-Module Splatter, then Initialize-Splatter -Verb Get,Use,Find -Minify ) |
Oops, something went wrong.