mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Some improvements to the powershell modules
Make open-solution more reliable. Add some variables that will get used various other places
This commit is contained in:
@@ -14,17 +14,18 @@ Function Open-Solution {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$false, HelpMessage="The path to the solution file to open.")]
|
||||
[Uri]$SolutionFilePath = (Resolve-Path "../Terminal.sln")
|
||||
[ValidatePattern(".*Terminal\.sln" )]
|
||||
[string]$Path = $SolutionFilePath
|
||||
)
|
||||
|
||||
if(!$IsWindows) {
|
||||
[string]$warningMessage = "The Open-Solution cmdlet is only supported on Windows.`n`
|
||||
Attempt to open file $SolutionFilePath with the system default handler?"
|
||||
Attempt to open file $Path with the system default handler?"
|
||||
|
||||
Write-Warning $warningMessage -WarningAction Inquire
|
||||
}
|
||||
|
||||
Invoke-Item $SolutionFilePath
|
||||
Invoke-Item $Path
|
||||
return
|
||||
}
|
||||
|
||||
@@ -62,6 +63,13 @@ Function Set-PowerShellEnvironment {
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
# Set up some common globals
|
||||
New-Variable -Name ScriptsDirectory -Value $PSScriptRoot -Option ReadOnly -Scope Global -Visibility Public
|
||||
New-Variable -Name RepositoryRootDirectory -Value (Join-Path -Resolve $ScriptsDirectory "..") -Option ReadOnly -Scope Global -Visibility Public
|
||||
New-Variable -Name SolutionFilePath -Value (Join-Path -Resolve $RepositoryRootDirectory "Terminal.sln") -Option ReadOnly -Scope Global -Visibility Public
|
||||
New-Variable -Name TerminalGuiProjectDirectory -Value (Join-Path -Resolve $RepositoryRootDirectory "Terminal.Gui") -Option ReadOnly -Scope Global -Visibility Public
|
||||
New-Variable -Name TerminalGuiProjectFilePath -Value (Join-Path -Resolve $TerminalGuiProjectDirectory "Terminal.Gui.csproj") -Option ReadOnly -Scope Global -Visibility Public
|
||||
|
||||
# Set a custom prompt to indicate we're in our modified environment.
|
||||
# Save the normal one first, though.
|
||||
# And save it as ReadOnly and without the -Force parameter, so this will be skipped if run more than once in the same session without a reset.
|
||||
@@ -132,6 +140,11 @@ Function Reset-PowerShellEnvironment {
|
||||
}
|
||||
|
||||
Remove-Variable -Name PathVarSeparator -Scope Global -Force -ErrorAction SilentlyContinue
|
||||
Remove-Variable -Name RepositoryRootDirectory -Scope Global -Force -ErrorAction SilentlyContinue
|
||||
Remove-Variable -Name SolutionFilePath -Scope Global -Force -ErrorAction SilentlyContinue
|
||||
Remove-Variable -Name TerminalGuiProjectDirectory -Scope Global -Force -ErrorAction SilentlyContinue
|
||||
Remove-Variable -Name TerminalGuiProjectFilePath -Scope Global -Force -ErrorAction SilentlyContinue
|
||||
Remove-Variable -Name ScriptsDirectory -Scope Global -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# This ensures the environment is reset when unloading the module.
|
||||
@@ -140,4 +153,4 @@ $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = {
|
||||
Reset-PowerShellEnvironment
|
||||
}
|
||||
|
||||
Set-PowerShellEnvironment
|
||||
Set-PowerShellEnvironment
|
||||
|
||||
Reference in New Issue
Block a user