-
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.
- Loading branch information
Showing
9 changed files
with
137 additions
and
134 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,136 +1,23 @@ | ||
<#PSScriptInfo | ||
.VERSION 0.1.0 | ||
.GUID 58655ac6-8750-4397-a15f-29f9e18e257d | ||
.AUTHOR Kitsune Solar | ||
.AUTHOREMAIL [email protected] | ||
.COMPANYNAME iHub.TO | ||
.COPYRIGHT 2023 Kitsune Solar. All rights reserved. | ||
.LICENSEURI https://github.com/pkgstore/pwsh-kernel/blob/main/LICENSE | ||
.PROJECTURI | ||
#> | ||
|
||
function Write-Msg() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('T')][string]$Type, | ||
[Alias('M')][string]$Message, | ||
[Alias('A')][string]$Action = 'Continue' | ||
) | ||
|
||
switch ($Type) { | ||
'HL' { Write-Host "${NL}--- ${Message}".ToUpper() -ForegroundColor Blue } | ||
'I' { Write-Information -MessageData "${Message}" -InformationAction "${Action}" } | ||
'W' { Write-Warning -Message "${Message}" -WarningAction "${Action}" } | ||
'E' { Write-Error -Message "${Message}" -ErrorAction "${Action}" } | ||
default { Write-Host "${Message}" } | ||
} | ||
} | ||
|
||
function Test-Module() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
Param( | ||
[Parameter(Mandatory)][Alias('N')][string[]]$Names | ||
) | ||
|
||
$Names | ForEach-Object { | ||
if (-not (Get-Module -ListAvailable -Name "${_}")) { | ||
Write-Error -Message "Module '${_}' not installed!" -ErrorAction 'Stop' | ||
} | ||
$Aliases = @() | ||
$PrivateFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Private') -Include '*.ps1' -File -Recurse) | ||
$PublicFunctions = (Get-ChildItem -Path (Join-Path $PSScriptRoot 'Public') -Include '*.ps1' -File -Recurse) | ||
|
||
(@($PrivateFunctions) + @($PublicFunctions)) | ForEach-Object { | ||
try { | ||
Write-Verbose "Loading '$($_.FullName)'." | ||
. $_.FullName | ||
} catch { | ||
Write-Warning $_.Exception.Message | ||
} | ||
} | ||
|
||
function Test-Data() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('T')][string]$Type, | ||
[Alias('P')][string]$Path | ||
) | ||
@($PublicFunctions) | ForEach-Object { | ||
$Alias = (Get-Alias -Definition $_.BaseName -ErrorAction 'SilentlyContinue') | ||
|
||
switch ($Type) { | ||
'D' { $Type = 'Container' } | ||
'F' { $Type = 'Leaf' } | ||
if ($Alias) { | ||
$Aliases += $Alias | ||
Export-ModuleMember -Function $_.BaseName -Alias $Alias | ||
} else { | ||
Export-ModuleMember -Function $_.BaseName | ||
} | ||
|
||
Test-Path -LiteralPath "${Path}" -PathType "${Type}" | ||
} | ||
|
||
function New-Data() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('T')][string]$Type, | ||
[Alias('P')][string]$Path, | ||
[Alias('N')][string]$Name, | ||
[Alias('A')][string]$Action = 'SilentlyContinue' | ||
) | ||
|
||
switch ($Type) { | ||
'D' { $Type = 'Directory' } | ||
'F' { $Type = 'File' } | ||
} | ||
|
||
New-Item -Path "${Path}" -Name "${Name}" -ItemType "${Type}" -ErrorAction "${Action}" | ||
} | ||
|
||
function Copy-Data() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('S')][string]$Src, | ||
[Alias('D')][string]$Dst | ||
) | ||
|
||
Copy-Item -LiteralPath "${Src}" -Destination "${Dst}" -Force | ||
} | ||
|
||
function Move-Data() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('S')][string]$Src, | ||
[Alias('D')][string]$Dst | ||
) | ||
|
||
Move-Item -LiteralPath "${Src}" -Destination "${Dst}" -Force | ||
} | ||
|
||
function Remove-Data() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('P')][string]$Path | ||
) | ||
|
||
Remove-Item -LiteralPath "${Path}" -Force | ||
} |
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,14 @@ | ||
function Copy-Data() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('S')][string]$Src, | ||
[Alias('D')][string]$Dst | ||
) | ||
|
||
Copy-Item -LiteralPath "${Src}" -Destination "${Dst}" -Force | ||
} |
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,14 @@ | ||
function Move-Data() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('S')][string]$Src, | ||
[Alias('D')][string]$Dst | ||
) | ||
|
||
Move-Item -LiteralPath "${Src}" -Destination "${Dst}" -Force | ||
} |
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,21 @@ | ||
function New-Data() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('T')][string]$Type, | ||
[Alias('P')][string]$Path, | ||
[Alias('N')][string]$Name, | ||
[Alias('A')][string]$Action = 'SilentlyContinue' | ||
) | ||
|
||
switch ($Type) { | ||
'D' { $Type = 'Directory' } | ||
'F' { $Type = 'File' } | ||
} | ||
|
||
New-Item -Path "${Path}" -Name "${Name}" -ItemType "${Type}" -ErrorAction "${Action}" | ||
} |
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,13 @@ | ||
function Remove-Data() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('P')][string]$Path | ||
) | ||
|
||
Remove-Item -LiteralPath "${Path}" -Force | ||
} |
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,19 @@ | ||
function Test-Data() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('T')][string]$Type, | ||
[Alias('P')][string]$Path | ||
) | ||
|
||
switch ($Type) { | ||
'D' { $Type = 'Container' } | ||
'F' { $Type = 'Leaf' } | ||
} | ||
|
||
Test-Path -LiteralPath "${Path}" -PathType "${Type}" | ||
} |
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 @@ | ||
function Test-Module() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
Param( | ||
[Parameter(Mandatory)][Alias('N')][string[]]$Names | ||
) | ||
|
||
$Names | ForEach-Object { | ||
if (-not (Get-Module -ListAvailable -Name "${_}")) { | ||
Write-Error -Message "Module '${_}' not installed!" -ErrorAction 'Stop' | ||
} | ||
} | ||
} |
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,21 @@ | ||
function Write-Msg() { | ||
<# | ||
.SYNOPSIS | ||
.DESCRIPTION | ||
#> | ||
|
||
param ( | ||
[Alias('T')][string]$Type, | ||
[Alias('M')][string]$Message, | ||
[Alias('A')][string]$Action = 'Continue' | ||
) | ||
|
||
switch ($Type) { | ||
'HL' { Write-Host "${NL}--- ${Message}".ToUpper() -ForegroundColor Blue } | ||
'I' { Write-Information -MessageData "${Message}" -InformationAction "${Action}" } | ||
'W' { Write-Warning -Message "${Message}" -WarningAction "${Action}" } | ||
'E' { Write-Error -Message "${Message}" -ErrorAction "${Action}" } | ||
default { Write-Host "${Message}" } | ||
} | ||
} |