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
|
||||
Generates manuals from the scripts
|
||||
Exports all scripts as manuals
|
||||
.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
|
||||
PS> ./export-scripts2manuals.ps1
|
||||
Found 264 scripts, starting export to /home/markus/PowerShell/Docs...
|
||||
✔️ exported 264 scripts as manuals in 28 sec
|
||||
.NOTES
|
||||
Author: Markus Fleschutz · License: CC0
|
||||
.LINK
|
||||
@ -13,21 +15,21 @@
|
||||
|
||||
#requires -version 2
|
||||
|
||||
param([string]$FilePattern = "$PSScriptRoot/*.ps1")
|
||||
param([string]$FilePattern = "$PSScriptRoot/*.ps1", [string]$TargetDir = "$PSScriptRoot/../Docs")
|
||||
|
||||
try {
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
$Scripts = Get-ChildItem "$FilePattern"
|
||||
"Found $($Scripts.Count) scripts, starting export..."
|
||||
"Found $($Scripts.Count) scripts, starting export to $TargetDir..."
|
||||
|
||||
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
|
||||
"✔️ exported $($Scripts.Count) scripts to manuals in $Elapsed sec"
|
||||
exit 0
|
||||
"✔️ exported $($Scripts.Count) scripts as manuals in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
|
@ -1,32 +1,40 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
← enter overview of script here
|
||||
Exports all scripts to Serenade for voice control
|
||||
.DESCRIPTION
|
||||
← enter brief description of script here
|
||||
.INPUTS
|
||||
← enter inputs here (if any, otherwise state None)
|
||||
.OUTPUTS
|
||||
← enter outputs here (if any, otherwise state None)
|
||||
This script exports all PowerShell scripts to Serenade.ai for voice control.
|
||||
.EXAMPLE
|
||||
PS> .\template.ps1 ← enter example here (repeat this attribute for more than one example)
|
||||
PS> ./export-scripts2serenade.ps1
|
||||
.NOTES
|
||||
Author: ← enter full name here
|
||||
License: ← enter license here
|
||||
Author: Markus Fleschutz · License: CC0
|
||||
.LINK
|
||||
← enter URL here
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
#requires -version 4
|
||||
#requires -version 2
|
||||
|
||||
param() # ← enter script parameters here
|
||||
|
||||
# ← enter functions here
|
||||
param([string]$FilePattern = "$PSScriptRoot/*.ps1", [string]$TargetFile = "$HOME/.serenade/scripts/PowerShell.js")
|
||||
|
||||
try {
|
||||
# ← enter instructions here
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
"✔️ Done."
|
||||
exit 0
|
||||
$Scripts = Get-ChildItem "$FilePattern"
|
||||
"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 {
|
||||
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user