|
@@ -13,27 +13,27 @@
|
|
|
# * --stow
|
|
|
# * --delete
|
|
|
# * --restow
|
|
|
-# * --verbose
|
|
|
+# * --verbose (bool not int!)
|
|
|
# * --simulate
|
|
|
# * No tree folding by default (regardless of --nofolding option)
|
|
|
#
|
|
|
|
|
|
+[CmdletBinding()]
|
|
|
param(
|
|
|
- [Parameter(Mandatory = $true)][string]$Source,
|
|
|
- [Parameter(Mandatory = $true)][string]$Target,
|
|
|
- [string]$Dir,
|
|
|
+ [Parameter(Mandatory = $true)][string]$Dir,
|
|
|
+ [Parameter(Mandatory = $true)][string]$Package,
|
|
|
+ [string]$Target,
|
|
|
[string]$Ignore,
|
|
|
[string]$Defer,
|
|
|
[string]$Override,
|
|
|
[switch]$Restow,
|
|
|
[switch]$Delete,
|
|
|
- [int]$Verbose = 0,
|
|
|
[switch]$Simulate,
|
|
|
[switch]$NoFolding,
|
|
|
[switch]$Adopt
|
|
|
)
|
|
|
|
|
|
-$SourcePath = (Resolve-Path $Source).Path
|
|
|
+$SourcePath = (Resolve-Path $Dir).Path
|
|
|
$SourceRoot = [System.IO.Path]::GetFullPath($SourcePath)
|
|
|
$TargetRoot = [System.IO.Path]::GetFullPath($Target)
|
|
|
|
|
@@ -43,18 +43,12 @@ function Is-Under($child, $parent) {
|
|
|
return $child.StartsWith($parent, [System.StringComparison]::OrdinalIgnoreCase)
|
|
|
}
|
|
|
|
|
|
-function Write-Log($msg) {
|
|
|
- if ($Verbose -ge 2) {
|
|
|
- Write-Host $msg
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
if ($Delete -or $Restow) {
|
|
|
Get-ChildItem -Path $TargetRoot -Recurse -Force | ForEach-Object {
|
|
|
if ($_.LinkType -eq 'SymbolicLink') {
|
|
|
$linkTarget = (Get-Item $_.FullName -Force).Target
|
|
|
if ($linkTarget -and (Is-Under $linkTarget $SourceRoot)) {
|
|
|
- Write-Log "Unlinking: $($_.FullName) -> $linkTarget"
|
|
|
+ Write-Verbose "Unlinking: $($_.FullName) -> $linkTarget"
|
|
|
if (-not $Simulate) {
|
|
|
Remove-Item $_.FullName
|
|
|
}
|
|
@@ -71,13 +65,13 @@ if ($Stow -or $Restow) {
|
|
|
$targetDir = Split-Path $targetFile
|
|
|
|
|
|
if (-not (Test-Path $targetDir)) {
|
|
|
- Write-Log "Creating dir: $targetDir"
|
|
|
+ Write-Verbose "Creating dir: $targetDir"
|
|
|
if (-not $Simulate) {
|
|
|
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Write-Log "Linking: $targetFile -> $($_.FullName)"
|
|
|
+ Write-Verbose "Linking: $targetFile -> $($_.FullName)"
|
|
|
if (-not $Simulate) {
|
|
|
New-Item -ItemType SymbolicLink -Path $targetFile -Target $_.FullName | Out-Null
|
|
|
}
|