-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGet-OpenSpecToolchain.ps1
More file actions
29 lines (25 loc) · 1.11 KB
/
Get-OpenSpecToolchain.ps1
File metadata and controls
29 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function Get-OpenSpecToolchain {
[CmdletBinding()]
param(
[switch]$RequireDocxConverter
)
$pythonCommand = Get-Command -Name 'python' -ErrorAction SilentlyContinue
$doclingCommand = Get-Command -Name 'docling' -ErrorAction SilentlyContinue
$markitdownCommand = Get-Command -Name 'markitdown' -ErrorAction SilentlyContinue
$openXmlModule = Get-Module -ListAvailable -Name 'OpenXML' | Select-Object -First 1
$toolchain = [pscustomobject]@{
PSTypeName = 'AwakeCoding.OpenSpecs.Toolchain'
PythonPath = $pythonCommand.Source
DoclingPath = $doclingCommand.Source
MarkItDownPath = $markitdownCommand.Source
OpenXmlModulePath = if ($openXmlModule) { $openXmlModule.Path } else { $null }
HasPython = $null -ne $pythonCommand
HasDocling = $null -ne $doclingCommand
HasMarkItDown = $null -ne $markitdownCommand
HasOpenXml = $null -ne $openXmlModule
}
if ($RequireDocxConverter -and -not $toolchain.HasOpenXml) {
throw 'No DOCX converter detected. Install the OpenXML PowerShell module.'
}
return $toolchain
}