You've already forked SharedScripts
mirror of
https://github.com/jaapbrasser/SharedScripts.git
synced 2026-04-18 19:01:56 +02:00
Added parameters
This commit is contained in:
@@ -1,15 +1,38 @@
|
||||
function New-GitHubMarkdownIndex {
|
||||
param(
|
||||
$Path = 'C:\Temp\Events',
|
||||
$GitHubUri = 'https://github.com/jaapbrasser/events/tree/master'
|
||||
[string] $Path = 'C:\Temp\Events',
|
||||
[string] $GitHubUri = 'https://github.com/jaapbrasser/events/tree/master',
|
||||
[string[]] $IncludeExtensions = @('.md','pdf','.123','123','234','.234'),
|
||||
[switch] $NoClipBoard
|
||||
)
|
||||
Get-ChildItem -LiteralPath $Path | % {
|
||||
$GHPath = $_.FullName -replace [regex]::Escape($Path) -replace '\\','/' -replace '\s','%20'
|
||||
"* [$(Split-Path $_ -Leaf)]($GitHubUri$GHPath)"
|
||||
$_ | ls -recurse | ? {$_.PSIsContainer -or $_.Extension -eq '.md'} | select -exp fullname | % {
|
||||
$Count = ($_ -split '\\').Count-($Path.Split('\').Count+1)
|
||||
$GHPath = $_ -replace [regex]::Escape($Path) -replace '\\','/' -replace '\s','%20'
|
||||
"$(" "*$Count*2)* [$(Split-Path $_ -Leaf)]($GitHubUri$GHPath)"
|
||||
|
||||
begin {
|
||||
$IncludeExtensions = $IncludeExtensions | ForEach-Object {
|
||||
if ($_ -notmatch '^\.') {
|
||||
".$_"
|
||||
} else {
|
||||
$_
|
||||
}
|
||||
}
|
||||
} | clip.exe
|
||||
|
||||
$BuildMarkDown = {
|
||||
Get-ChildItem -LiteralPath $Path | ForEach-Object {
|
||||
$GHPath = $_.FullName -replace [regex]::Escape($Path) -replace '\\','/' -replace '\s','%20'
|
||||
"* [$(Split-Path $_ -Leaf)]($GitHubUri$GHPath)"
|
||||
$_ | Get-ChildItem -Recurse | ? {$_.PSIsContainer -or $_.Extension -in $IncludeExtensions} | ForEach-Object {
|
||||
$Count = ($_.FullName -split '\\').Count-($Path.Split('\').Count+1)
|
||||
$GHPath = $_.FullName -replace [regex]::Escape($Path) -replace '\\','/' -replace '\s','%20'
|
||||
"$(" "*$Count*2)* [$(Split-Path $_ -Leaf)]($GitHubUri$GHPath)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
process {
|
||||
if ($NoClipBoard) {
|
||||
$BuildMarkDown.Invoke()
|
||||
} else {
|
||||
$BuildMarkDown.Invoke() | clip.exe
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user