|
15 | 15 | The target channel for Feature checks (default=Experimental). |
16 | 16 |
|
17 | 17 | .PARAMETER Output |
18 | | - File to create (default=stdout). |
| 18 | + File to create (default=stdout). If a directory the filename is derived from the input filename (-Path) and the language. |
19 | 19 |
|
20 | 20 | .PARAMETER Language |
21 | 21 | Programming language to generate (default=C++). |
@@ -67,6 +67,17 @@ if ([String]::IsNullOrEmpty($Namespace)) |
67 | 67 | } |
68 | 68 | } |
69 | 69 |
|
| 70 | +# Generate the output base name derived from input base name and language if the input filename (-Path) is a directory |
| 71 | +$Output_Original = $Output |
| 72 | +if (Test-Path -Path $Output -PathType Container) |
| 73 | +{ |
| 74 | + $path_filename = Split-Path -Path $Path -Leaf |
| 75 | + $path_basename = $path_filename -replace '\.[^.]*$', '' |
| 76 | + $extension = @{ 'C++'='.h'; 'C#'='.cs' }[$Language] |
| 77 | + $filename = $path_basename + $extension |
| 78 | + $Output = Join-Path $Output $filename |
| 79 | +} |
| 80 | + |
70 | 81 | Enum State |
71 | 82 | { |
72 | 83 | AlwaysDisabled; |
@@ -96,7 +107,7 @@ Class Feature |
96 | 107 | $this.Name = $entry.name |
97 | 108 | $this.State = ConvertTo-FeatureState $entry.state |
98 | 109 |
|
99 | | - # TODO: Remove the temp workaround of downgrading to StrictModel 1.0 once b#52128443 is fixed. |
| 110 | + # TODO: Remove the temp workaround of downgrading to StrictModel 1.0 once b#52128443 is fixed. |
100 | 111 | Set-StrictMode -Version 1.0 |
101 | 112 | $this.Id = $entry.id |
102 | 113 | $this.ChannelTokenStates = [System.Collections.Generic.Dictionary[string, State]]::new() |
@@ -206,7 +217,7 @@ $comment_line_prefix Licensed under the MIT License. |
206 | 217 | $comment_line_prefix THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT IT |
207 | 218 |
|
208 | 219 | $comment_line_prefix INPUT FILE: $Path |
209 | | -$comment_line_prefix OPTIONS: -Channel $Channel -Language $Language$(if (-not ([String]::IsNullOrEmpty($Namespace))) { " -Namespace $Namespace" }) -Path $Path$(if (-not ([String]::IsNullOrEmpty($Output))) { " -Output $Output" }) |
| 220 | +$comment_line_prefix OPTIONS: -Channel $Channel -Language $Language$(if (-not ([String]::IsNullOrEmpty($Namespace))) { " -Namespace $Namespace" }) -Path $Path$(if (-not ([String]::IsNullOrEmpty($Output))) { " -Output $Output_Original" }) |
210 | 221 |
|
211 | 222 |
|
212 | 223 | "@ |
|
0 commit comments