Skip to content

Commit 7920768

Browse files
author
Kapil Borle
committed
Make invoke-formatter parameters positional
1 parent 6a2a9d6 commit 7920768

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

Engine/Commands/InvokeFormatterCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public class InvokeFormatterCommand : PSCmdlet, IOutputWriter
3333
///
3434
/// *NOTE*: Unlike ScriptBlock parameter, the ScriptDefinition parameter require a string value.
3535
/// </summary>
36-
[ParameterAttribute(Mandatory = true)]
36+
[ParameterAttribute(Mandatory = true, Position = 1)]
3737
[ValidateNotNull]
3838
public string ScriptDefinition { get; set; }
3939

4040
/// <summary>
4141
/// A settings hashtable or a path to a PowerShell data file (.psd1) file that contains the settings.
4242
/// </summary>
43-
[Parameter(Mandatory = false)]
43+
[Parameter(Mandatory = false, Position = 2)]
4444
[ValidateNotNull]
4545
public object Settings { get; set; }
4646

Tests/Engine/InvokeFormatter.tests.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ Import-Module PSScriptAnalyzer
55
Import-Module (Join-Path $testRootDirectory "PSScriptAnalyzerTestHelper.psm1")
66

77
Describe "Invoke-Formatter Cmdlet" {
8+
Context "When positional parameters are given" {
9+
It "Should use the positional parameters" {
10+
$def = @"
11+
function foo {
12+
"abc"
13+
}
14+
"@
15+
16+
$expected = @"
17+
function foo {
18+
"abc"
19+
}
20+
"@
21+
22+
$settings = @{
23+
IncludeRules = @('PSUseConsistentIndentation')
24+
Rules = @{
25+
PSUseConsistentIndentation = @{
26+
Enable = $true
27+
}
28+
}
29+
}
30+
31+
Invoke-Formatter $def $settings | Should Be $expected
32+
}
33+
}
834
Context "When no settings are given" {
935
It "Should format using default settings" {
1036
$def = @'

0 commit comments

Comments
 (0)