Check-in [74c2c89475]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Shorten starter.ps1 with `Is-PluginCompatible` function, scanning user plugins with standard scripts, and moving -Filter to separate script. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
74c2c894759aa562ef70b16f71465b62 |
User & Date: | mario 2018-05-19 22:47:21 |
Context
2018-05-19
| ||
22:49 | New menu/plugin which adds dummy entries for unclassified scripts. Leaf check-in: 168d091f87 user: mario tags: trunk | |
22:47 | Shorten starter.ps1 with `Is-PluginCompatible` function, scanning user plugins with standard scripts, and moving -Filter to separate script. check-in: 74c2c89475 user: mario tags: trunk | |
2018-05-18
| ||
17:58 | Attempt at making TreeViewItems more solid (metro/burger style menu) check-in: 16ea606fae user: mario tags: trunk | |
Changes
Changes to modules/menu.psm1.
︙ | ︙ | |||
174 175 176 177 178 179 180 181 182 183 184 185 186 187 | $meta.fn = "$fn" $meta.id = ($fn -replace "^.+[\\/]|\.\w+$","") -replace "[^\w]","_" $meta.doc = ($doc -join "`r`n") } return $meta # or return as (New-Object PSCustomObject -Prop $meta) } #-- script header function Init-Screen() { param($x=100,$y=45) #-- screen size // better than `mode con` as it retains scrolling: if ($host.Name -match "Console") { $con = $host.UI.RawUI | > > > > > > > | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | $meta.fn = "$fn" $meta.id = ($fn -replace "^.+[\\/]|\.\w+$","") -replace "[^\w]","_" $meta.doc = ($doc -join "`r`n") } return $meta # or return as (New-Object PSCustomObject -Prop $meta) } #-- general PMD check function Is-PluginCompatible { Param($m) $m.type -and $m.title -and $m.category -and ($m.api -match "mt|multitool|clicky|ps|powershell|automat|^$") } #-- script header function Init-Screen() { param($x=100,$y=45) #-- screen size // better than `mode con` as it retains scrolling: if ($host.Name -match "Console") { $con = $host.UI.RawUI |
︙ | ︙ | |||
196 197 198 199 200 201 202 | try { $host.UI.RawUI.WindowTitle = $meta.title } catch { } } #-- group plugin list by category, sort by sort: / key: / title: function Sort-Menu($menu) { $usort_cat = { (@{cmd=1; user=2; powershell=3; onbehalf=11; exchange=4; empirum=5; network=6; info=7; wmi=8}[$_.category], $_.category) -ne $null } $usort_key = { if ($_.key -match "(\d+)") { [int]$matches[1] } else { $_.key } } | | | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | try { $host.UI.RawUI.WindowTitle = $meta.title } catch { } } #-- group plugin list by category, sort by sort: / key: / title: function Sort-Menu($menu) { $usort_cat = { (@{cmd=1; user=2; powershell=3; onbehalf=11; exchange=4; empirum=5; network=6; info=7; wmi=8}[$_.category], $_.category) -ne $null } $usort_key = { if ($_.key -match "(\d+)") { [int]$matches[1] } else { $_.key } } return ($menu | ? { $_.title -and $_.category } | Sort-Object $usort_cat, {$_.sort}, $usort_key, {$_.title}) } #-- string cutting function substr($str, $from, $to) { if ($to -lt $str.length) { $str.substring($from, $to) } |
︙ | ︙ |
Changes to modules/starter.ps1.
︙ | ︙ | |||
57 58 59 60 61 62 63 | } $global:plugins = @{ "init" = @() "before" = @() "after" = @() "menu" = @() } | > > | | > | < | < < | | | | < < < < < < < | | < < < < < < < < < | | | | | | | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | } $global:plugins = @{ "init" = @() "before" = @() "after" = @() "menu" = @() } #-- add user config cd ($cfg.multitool_base) if (Test-Path ($cfg.user_config_fn)) { . ($cfg.user_config_fn) } if (Test-Path ($cfg.user_plugins_d)) { $cfg.tool_dirs += @($cfg.user_plugins_d+"/*.ps1") } if ($Debug) { $cfg|FL } #-- modules $ENV:PSModulePath += ";$($cfg.multitool_base)\modules" $global:GUI = [hashtable]::Synchronized(@{Host=$Host}) Import-Module -DisableNameChecking "$($cfg.multitool_base)\modules\guimenu.psm1" Write-Splash "Loading Modules.." 30 Import-Module -DisableNameChecking "$($cfg.multitool_base)\modules\menu.psm1" Import-Module -DisableNameChecking "$($cfg.multitool_base)\modules\clipboard.psm1" if (!(Get-Module -Name ActiveDirectory)) { Import-Module ActiveDirectory } #-- scan tools/plugins Write-Splash "Scanning Plugins.." 120 $cfg.main = (Extract-PluginMeta $cfg.curr_script_fn) #-- collect entries $menu = @() $menu += @(Get-Item ($cfg.tool_dirs) | % { Extract-PluginMeta $_ } | ? { Is-PluginCompatible $_ }) #-- run `type:init` plugins here Write-Splash "Init Plugins.." 55 $menu | ? { $_.type -eq "init" -and $_.fn } | % { try { . $_.fn } catch { Write-Host -f Red "Failure init plugin: $($_.fn)" $PSItem | FL | Out-String | Write-Host -f Gray } } #-- CLI mode if ($CLI) { Write-Splash "Done" 1000 cls ; Init-Screen |
︙ | ︙ |
Added tools/plugins/menu_filter.ps1.
> > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # api: multitool # type: init # title: apply $menu -Filter # description: handles cmdline args -Filter and -NotFilter # version: 0.1 # category: core # priority: core # status: stable # # Removes entries from global $menu[] if the fit -Filter parameter. Which is # used for "ClickyInfo" starter. # # e.g. $Filter="info|user|wmi" to show only a subset of safe/read-only scripts if ($Filter) { $menu = $menu | ? { (($_.category, $_.fn, $_.description, $_.title) -match $Filter) } | ? { -not (($_.category, $_.fn, $_.description, $_.title) -match $NotFilter) } } |