mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 09:04:18 +01:00
Update export-scripts2manuals.ps1 and export-scripts2serenade.ps1
This commit is contained in:
parent
cd3fe1fe12
commit
989ddd6a38
@ -1,10 +1,12 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Generates manuals from the scripts
|
Exports all scripts as manuals
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This script exports the comment based help of all scripts to the manuals.
|
This script exports the comment based help of all PowerShell scripts as manuals.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./export-scripts2manuals.ps1
|
PS> ./export-scripts2manuals.ps1
|
||||||
|
Found 264 scripts, starting export to /home/markus/PowerShell/Docs...
|
||||||
|
✔️ exported 264 scripts as manuals in 28 sec
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz · License: CC0
|
Author: Markus Fleschutz · License: CC0
|
||||||
.LINK
|
.LINK
|
||||||
@ -13,21 +15,21 @@
|
|||||||
|
|
||||||
#requires -version 2
|
#requires -version 2
|
||||||
|
|
||||||
param([string]$FilePattern = "$PSScriptRoot/*.ps1")
|
param([string]$FilePattern = "$PSScriptRoot/*.ps1", [string]$TargetDir = "$PSScriptRoot/../Docs")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
$Scripts = Get-ChildItem "$FilePattern"
|
$Scripts = Get-ChildItem "$FilePattern"
|
||||||
"Found $($Scripts.Count) scripts, starting export..."
|
"Found $($Scripts.Count) scripts, starting export to $TargetDir..."
|
||||||
|
|
||||||
foreach ($Script in $Scripts) {
|
foreach ($Script in $Scripts) {
|
||||||
& "$PSScriptRoot/convert-ps2md" "$Script" > "$PSScriptRoot/../Docs/$($Script.BaseName).md"
|
& "$PSScriptRoot/convert-ps2md" "$Script" > "$TargetDir/$($Script.BaseName).md"
|
||||||
}
|
}
|
||||||
|
|
||||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
"✔️ exported $($Scripts.Count) scripts to manuals in $Elapsed sec"
|
"✔️ exported $($Scripts.Count) scripts as manuals in $Elapsed sec"
|
||||||
exit 0
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -1,32 +1,40 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
← enter overview of script here
|
Exports all scripts to Serenade for voice control
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
← enter brief description of script here
|
This script exports all PowerShell scripts to Serenade.ai for voice control.
|
||||||
.INPUTS
|
|
||||||
← enter inputs here (if any, otherwise state None)
|
|
||||||
.OUTPUTS
|
|
||||||
← enter outputs here (if any, otherwise state None)
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> .\template.ps1 ← enter example here (repeat this attribute for more than one example)
|
PS> ./export-scripts2serenade.ps1
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: ← enter full name here
|
Author: Markus Fleschutz · License: CC0
|
||||||
License: ← enter license here
|
|
||||||
.LINK
|
.LINK
|
||||||
← enter URL here
|
https://github.com/fleschutz/PowerShell
|
||||||
#>
|
#>
|
||||||
|
|
||||||
#requires -version 4
|
#requires -version 2
|
||||||
|
|
||||||
param() # ← enter script parameters here
|
param([string]$FilePattern = "$PSScriptRoot/*.ps1", [string]$TargetFile = "$HOME/.serenade/scripts/PowerShell.js")
|
||||||
|
|
||||||
# ← enter functions here
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
# ← enter instructions here
|
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||||
|
|
||||||
"✔️ Done."
|
$Scripts = Get-ChildItem "$FilePattern"
|
||||||
exit 0
|
"Found $($Scripts.Count) scripts, starting export to $TargetFile..."
|
||||||
|
|
||||||
|
"/* Exported by export-scripts2serenade.ps1 */" > $TargetFile
|
||||||
|
foreach ($Script in $Scripts) {
|
||||||
|
$ScriptName = $Script.basename
|
||||||
|
"" >> $TargetFile
|
||||||
|
"serenade.global().command(\"$ScriptName\", async (api) => {" >> $TargetFile
|
||||||
|
"await api.focusOrLaunchApplication(\"terminal\");" >> $TargetFile
|
||||||
|
"await api.typeText(\"$Script\");" >> $TargetFile
|
||||||
|
"await api.pressKey(\"return\");" >> $TargetFile
|
||||||
|
"});" >> $TargetFile
|
||||||
|
}
|
||||||
|
|
||||||
|
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||||
|
"✔️ exported $($Scripts.Count) scripts to Serenade in $Elapsed sec"
|
||||||
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user