Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate from test branch to main #7

Merged
merged 49 commits into from
Jan 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
1862b81
misc updates
ninmonkey Oct 31, 2021
1ad897f
Update ConvertTo-BitString.ps1
ninmonkey Oct 31, 2021
9f19e27
removed extra aliases
ninmonkey Nov 1, 2021
ea391ac
Fixed Label's Null Input error
ninmonkey Nov 1, 2021
f978cb3
Rewrite: Format-TypeName
ninmonkey Nov 3, 2021
dc4674a
Format-TypeName: allow nulls, empty, remove throw
ninmonkey Nov 4, 2021
fc65cdd
Format-TypeName: Fixed indirect recursion bug
ninmonkey Nov 4, 2021
2037b89
iter
ninmonkey Nov 4, 2021
0c2ed27
Update Format-TypeName.ps1
ninmonkey Nov 5, 2021
f6b0f49
Cleaned up Errorhandling
ninmonkey Nov 6, 2021
4d2c6fa
Misc tests added
ninmonkey Nov 7, 2021
dee336f
ResCmd: Optionally keep aliases in output
ninmonkey Nov 8, 2021
737c11f
Improved Format->RelativePath, now it's robust against inputs
ninmonkey Nov 8, 2021
d81223f
fixed Format-RelativePath null error
ninmonkey Nov 11, 2021
b87c576
cleaned up a few notes
ninmonkey Nov 14, 2021
379f5f4
Updating tests, and aliases, minor 'Label' fix
ninmonkey Nov 14, 2021
acc9630
renamed for clarity
ninmonkey Nov 15, 2021
36836ce
iter on format path
ninmonkey Nov 16, 2021
18f3ea9
New: Out-NinGridView
ninmonkey Nov 16, 2021
16a8fcb
Cleaning up aliases
ninmonkey Nov 17, 2021
8885de6
doc string
ninmonkey Nov 19, 2021
eb45efd
Added fail case to parse for later
ninmonkey Nov 21, 2021
3cd3daa
Update _enumerateMyCommand.tests.ps1
ninmonkey Nov 22, 2021
68a68f4
Test-IsDirectory
ninmonkey Nov 23, 2021
6628bec
Update Test-IsDirectory.ps1
ninmonkey Nov 23, 2021
2bb6822
renaming
ninmonkey Nov 23, 2021
1c1359c
New: Converts numbered filepaths
ninmonkey Nov 27, 2021
f701e26
Fixed command logic
ninmonkey Nov 27, 2021
91daf87
ConvertFrom-NumberedFilepath tests pass
ninmonkey Nov 27, 2021
3c12e4f
Renamed: ConvertTo-RelativePath
ninmonkey Nov 27, 2021
7e95044
rename
ninmonkey Dec 3, 2021
5165c02
you may pipe code directly to Indent-NinFormat , and cleanup
ninmonkey Dec 3, 2021
b492c3a
new dotnet completer
ninmonkey Dec 3, 2021
96f45ba
New: Test-IsSubDirectory
ninmonkey Dec 3, 2021
622a79e
Invoke-NinFormat works on files
ninmonkey Dec 3, 2021
1c2d248
New: To->Base64, From-Base64, with tests
ninmonkey Dec 8, 2021
a4a20c7
Update ConvertTo-RelativePath.ps1
ninmonkey Dec 27, 2021
f3497e9
New Command: Show-XmlPreview
ninmonkey Dec 27, 2021
840eb7a
New: Add-IndexProperty
ninmonkey Dec 27, 2021
ff710d4
minimal debug statements
ninmonkey Jan 9, 2022
db8ced8
refactoring Invoke-NinFormatter to two commandlets
ninmonkey Jan 10, 2022
40dafe7
.
ninmonkey Jan 10, 2022
545a3a0
rename
ninmonkey Jan 11, 2022
c45a503
misc renames
ninmonkey Jan 18, 2022
436ef3b
Join hashtables, new: Merge-HashtableList
ninmonkey Jan 19, 2022
f0612ca
Update Resolve-CommandName.tests.ps1
ninmonkey Jan 20, 2022
64bd748
bugfix: Test-IsDirectory was erroring on Empty String
ninmonkey Jan 21, 2022
279b6dd
Update Get-ObjectTypeHelp.ps1
ninmonkey Jan 23, 2022
0f15b22
Hashtable: Optionally mutate left input
ninmonkey Jan 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"editor.fontSize": 18,
"editor.fontSize": 15,
"editor.fontFamily": "'cascadia code pl', Consolas, 'Courier New', monospace"

}
18 changes: 7 additions & 11 deletions Ninmonkey.Console.psd1
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
#
# Module manifest for module 'Ninmonkey.Console'
#
# Generated by: cppmo_000
#
# Generated on: 7/10/2021

@{
@{

# Script module or binary module file associated with this manifest.
RootModule = 'Ninmonkey.Console.psm1'

# Version number of this module.
ModuleVersion = '0.1.1'
ModuleVersion = '0.1.6'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand All @@ -26,7 +19,7 @@
CompanyName = 'Jake Bolton'

# Copyright statement for this module
Copyright = '(c) Jake Bolton 2021'
Copyright = '(c) Jake Bolton 2021-2022'

# Description of the functionality provided by this module
Description = 'Utilities to improve the quality of interactive use, the Command Line'
Expand All @@ -51,7 +44,10 @@

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(
'Pansies', 'ClassExplorer'
'Pansies'
'ClassExplorer'
'Utility' # hard dependency for now
'functional'
)

# Assemblies that must be loaded prior to importing this module
Expand Down
67 changes: 29 additions & 38 deletions Ninmonkey.Console.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@
$PSDefaultParameterValues['Select-NinProperty:Out-Variable'] = 'SelProp'
$PSDefaultParameterValues['Write-ConsoleLabel:fg'] = '7FB2C1'
# $PSDefaultParameterValues['Write-Text:AsString'] = $true
try {
Set-PSReadLineKeyHandler -Key 'f5' -Function ShowCommandHelp -ea Stop #SilentlyContinue
}
catch {
# catch [System.Management.Automation.ParameterBindingValidationException] {
if ($_.ToString() -match 'Cannot validate argument on parameter ''Function''. The argument "ShowCommandHelp"') {
"Module PSReadline: version {0} is missing function: 'ShowCommandHelp'" -f @( (Get-Module PSReadLine).Version )
| Write-Warning
}
else {
throw $_

& {
$hasFunc = (Get-PSReadLineKeyHandler -Bound -Unbound | ForEach-Object Function ) -contains 'ShowCommandHelp'
if ($hasFunc) {
Set-PSReadLineKeyHandler -Key 'f12' -Function ShowCommandHelp
}
}

Set-PSReadLineOption -Colors @{
Comment = '#E58BEB' # " e[38;2;229;139;235m"
}
Expand Down Expand Up @@ -46,8 +41,7 @@ if ($False) {
if (Test-Path $FileName ) {
. $FileName
}
}
catch {
} catch {
Write-Error "public_autoloader error: '$fileName'"

}
Expand Down Expand Up @@ -84,8 +78,7 @@ if ($psEditor) {
foreach ($file in $private_seeminglySci) {
# Write-Warning "file: seeminglySci -> : $File"
if (Test-Path ('{0}\private\seeminglySci\{1}.ps1' -f $psscriptroot, $file)) {
}
else {
} else {
Write-Error "Import: failed: private_seeminglySci: private: $File"
}
. ('{0}\private\seeminglySci\{1}.ps1' -f $psscriptroot, $file)
Expand All @@ -102,8 +95,7 @@ $private = @(

foreach ($file in $private) {
if (Test-Path ('{0}\private\{1}.ps1' -f $psscriptroot, $file)) {
}
else {
} else {
Write-Error "Import: private: failed: private: $File"
}
. ('{0}\private\{1}.ps1' -f $psscriptroot, $file)
Expand All @@ -119,8 +111,7 @@ $public_NativeWrapper = @(
)
foreach ($file in $public_NativeWrapper) {
if (Test-Path ('{0}\public\native_wrapper\{1}.ps1' -f $psscriptroot, $file)) {
}
else {
} else {
Write-Error "Import: failed: public\native_wrapper: $File"
}
. ('{0}\public\native_wrapper\{1}.ps1' -f $psscriptroot, $file)
Expand Down Expand Up @@ -151,7 +142,7 @@ $public_toDotSource = @(
'Write-ConsoleLabel'
'Write-ConsoleHeader'
'Write-ConsoleNewline'
'Format-RelativePath'

'Format-Hashtable'
'Format-ControlChar'

Expand All @@ -167,7 +158,7 @@ $public_toDotSource = @(
'ConvertTo-Number'
'ConvertTo-HexString'
'ConvertTo-Base64String'
'ConvertTo-BitString'

'ConvertTo-PropertyList'

# inspection
Expand Down Expand Up @@ -208,7 +199,7 @@ $public_toDotSource = @(
'Format-FileSize'
'Format-NullText'
# 'ConvertTo-PropertyList'
'Test-IsDirectory'

'Get-NinCommandSyntax'
'Format-TypeName'
'Format-GenericTypeName'
Expand All @@ -232,8 +223,7 @@ $public_toDotSource = @(
foreach ($file in $public_toDotSource) {
if (Test-Path ('{0}\public\{1}.ps1' -f $psscriptroot, $file)) {
# good
}
else {
} else {
Write-Error "Import: failed: public: $File"
}
. ('{0}\public\{1}.ps1' -f $psscriptroot, $file)
Expand All @@ -258,7 +248,7 @@ $functionsToExport = @(
'Write-ConsoleLabel'
'Write-ConsoleHeader'
'Write-ConsoleNewline'
'Format-RelativePath'

'Find-GitRepo'
'Write-ConsoleHorizontalRule'

Expand All @@ -272,7 +262,7 @@ $functionsToExport = @(
'ConvertTo-Number'
'ConvertTo-HexString'
'ConvertTo-Base64String'
'ConvertTo-BitString'

'ConvertTo-PropertyList'


Expand Down Expand Up @@ -308,7 +298,7 @@ $functionsToExport = @(
'Format-ControlChar'
'Trace-NinCommand'

'Test-IsDirectory'

'Set-NinLocation'
'Get-NinCommandSyntax'
'Get-NinTypeData'
Expand All @@ -331,7 +321,7 @@ $functionsToExport = @(
'Test-Net'
# seemingly-sci
# 'Get-ElementName'
'ConvertTo-BitString'

'ConvertTo-Number'
'ConvertTo-HexString'
'ConvertTo-Base64String'
Expand Down Expand Up @@ -368,8 +358,7 @@ foreach ($typeName in $formatData) {
if (Test-Path $FileName ) {
Update-FormatData -PrependPath $FileName
Write-Verbose "Imported: FormatData: [$TypeName] $FileName"
}
else {
} else {
Write-Error "Import: failed: FormatData: [$TypeName] $FileName"
}
}
Expand All @@ -379,8 +368,12 @@ if ($true) {
New-Alias -ea 'Ignore' 'Docs' -Value 'Get-Docs' -Description 'Jump to docs by language'
New-Alias -ea 'Ignore' 'IPython' -Value 'Invoke-IPython' -Description 'ipython.exe defaults using my profile'

# now set as an alias: New-Alias -ea 'Ignore' 'Goto' -Value Set-NinLocation -Description 'a more flexible version of Set-Location / cd'
# this wasn't loading below, maybe because old system
New-Alias 'Select->Property' -Value Select-NinProperty



# now set as an alias: New-Alias -ea 'Ignore' 'Goto' -Value Set-NinLocation -Description 'a more flexible version of Set-Location / cd'
New-Alias -ea 'Ignore' 'Here' -Value Invoke-Explorer -Description 'Open paths in explorer'

# Set-Alias 'Cd' -Value 'Set-NinLocation' -ea Continue #todo: make this opt in
Expand All @@ -402,11 +395,7 @@ if ($true) {
'IPython'


# smart alias
## Select-NinProperty
'SelectProp' # Select-NinProperty:
'Select-Property' # Select-NinProperty:
'ListProp' # Select-NinProperty: smart alias
'Select->Property' # Select-NinProperty

'HelpHistory' # Find-HelpFromHistory

Expand Down Expand Up @@ -464,8 +453,7 @@ $FileName = ('{0}\public\completer\{1}' -f $psscriptroot, 'Completer-Loader.ps1'

if ( ($__ninConfig)?.HackSkipLoadCompleters ) {
Write-Warning '[w] root ⟹ Completer-Loader: Skipped'
}
else {
} else {

$curSplat = @{
# Verbose = -Verbose
Expand All @@ -477,4 +465,7 @@ else {
Build-CustomCompleter @curSplat
Import-CustomCompleter @curSplat
Import-GeneratedCompleter @curSplat

# this version works, run it last.
. (Get-Item (Join-Path $PSScriptRoot '/public/PSReadLine/native-dotnet-completer.ps1'))
}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ $PSDefaultParameterValues['Out-Fzf:OutVariable'] = 'Fzf'
🐒> $bytes | Base64
```

# Frequently used

```ps1
# Jump to modules
🐒> Get-Module PSKoans | Goto
pwd

C:\Users\monkey\Documents\PowerShell\Modules\PSKoans\0.67.1
```

# Console Encoding

```powershell
Expand Down
57 changes: 0 additions & 57 deletions private/seeminglySci/seeminglySci_import.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,63 +61,6 @@ param()
[section]: main
#>

function ConvertTo-SciBitString {
[Alias('Bits')]
[CmdletBinding(PositionalBinding = $false)]
param(
[Parameter(ValueFromPipeline)]
[psobject[]] $InputObject,

[Parameter(Position = 0)]
[ValidateRange(1, [int]::MaxValue)]
[int] $Padding,

[Parameter(Position = 1)]
[ValidateNotNull()]
[AllowEmptyString()]
[string] $ByteSeparator = ' ',

[Parameter(Position = 2)]
[ValidateNotNull()]
[AllowEmptyString()]
[string] $HalfByteSeparator = '.'
)
begin {
function GetBinaryString([psobject] $item) {
$numeric = number $item
if ($null -eq $numeric) {
return
}

$bits = [convert]::ToString($numeric, <# toBase: #> 2)
if ($PSCmdlet.MyInvocation.BoundParameters.ContainsKey((nameof { $Padding }))) {
$padAmount = $Padding * 8
if ($padAmount -ge $bits.Length) {
return $bits.PadLeft($Padding * 8, [char]'0')
}
}

$padAmount = 8 - ($bits.Length % 8)
if ($padAmount -eq 8) {
return $bits
}

return $bits.PadLeft($padAmount + $bits.Length, [char]'0')
}
}
process {
foreach ($currentItem in $InputObject) {
$binaryString = GetBinaryString $currentItem

# yield
$binaryString -replace
'[01]{8}(?=.)', "`$0$ByteSeparator" -replace
'[01]{4}(?=[01])', "`$0$HalfByteSeparator"
}
}
}


filter decimal { foreach ($currentItem in $PSItem) { Convert-Object -InputObject $currentItem -Type ([decimal]) } }
filter double { foreach ($currentItem in $PSItem) { Convert-Object -InputObject $currentItem -Type ([double]) } }
filter single { foreach ($currentItem in $PSItem) { Convert-Object -InputObject $currentItem -Type ([single]) } }
Expand Down
8 changes: 6 additions & 2 deletions public/ConvertTo-Base64String.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@

using namespace System.Text



# todo
function ConvertTo-Base64String {
<#
.synopsis
originally from: <ConvertTo-SciBase64String>
originally from: <Utility\ConvertTo-Base64String>
.notes
currently the same, separate same. separate for dependency clarity
.example
# For more see:
<./test/public/ConvertTo-Base64String.tests.ps1>
.link
Utility\ConvertTo-Base64String
#>
[Alias('Base64')]

Expand Down
Loading