-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add tab completion for Export-Counter -FileFormat parameter #3856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tab completion for Export-Counter -FileFormat parameter #3856
Conversation
edited
- Fixing Export-Counter -FileFormat <tab> does not show file format options. #3180
- Added ValidateSet to the -FileFormat parameter for possible log file types and updated the function that was previously validating the file formats.
- Removed the invalid format error message from resources files.
- Updated tests to reflect new FullyQualifiedErrorId.
@@ -180,9 +181,9 @@ protected override void BeginProcessing() | |||
_resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager(); | |||
|
|||
// | |||
// Validate the Format and CounterSamples arguments | |||
// Validate output format (log file type) and CounterSamples arguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not appear to be validating the format. Please correct the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -65,12 +65,13 @@ public string Path | |||
ValueFromPipelineByPropertyName = false, | |||
HelpMessageBaseName = "GetEventResources")] | |||
[ValidateNotNull] | |||
[ValidateSet("blg", "csv", "tsv", IgnoreCase = true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove IgnoreCase = true
- it is by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
ff1a99f
to
094ba3c
Compare
@@ -65,12 +65,13 @@ public string Path | |||
ValueFromPipelineByPropertyName = false, | |||
HelpMessageBaseName = "GetEventResources")] | |||
[ValidateNotNull] | |||
[ValidateSet("blg", "csv", "tsv")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have tab completion now, should they be spelled out? CommaSeperatedValues, TabSeperatedValues and BinaryLog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a chat with Jim. It is ok to keep them as is. Please open an issue on https://github.com/PowerShell/PowerShell-Docs/blob/staging/reference/5.1/Microsoft.PowerShell.Diagnostics/Export-Counter.md to explain what they mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file types are explained in the 'Description' section of the documentation. Did you want them in the 'Parameter' section as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MiaRomero Yes, please add them to the parameters section as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opened issue MicrosoftDocs/PowerShell-Docs#1245 for this
@@ -180,7 +180,7 @@ Describe "Feature tests for Export-Counter cmdlet" -Tags "Feature" { | |||
@{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test is not needed as it does not hit any code in the cmdlet. It hits Parameter Validation code paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed test case
@@ -311,26 +312,21 @@ protected override void ProcessRecord() | |||
} | |||
} | |||
|
|||
// ValidateFormat() helper. | |||
// Validates Format argument: only "BLG", "TSV" and "CSV" are valid strings (case-insensitive) | |||
// SetOutputFormat() helper. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line seems unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed line 314
@@ -180,9 +181,9 @@ protected override void BeginProcessing() | |||
_resourceMgr = Microsoft.PowerShell.Commands.Diagnostics.Common.CommonUtilities.GetResourceManager(); | |||
|
|||
// | |||
// Validate the Format and CounterSamples arguments | |||
// Set output format (log file type) and validate CounterSamples arguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update comment, SetOuputFormat does not do any validation anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated comment
@MiaRomero Please make your membership in the Microsoft Organization public. I sent instructions offline. #Resolved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#resolved
Please address @adityapatwardhan 's comments
@MiaRomero What is the status of this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a test case to TabCompletion.Tests.ps1
e3587dc
to
6633eff
Compare
Hi @TravisEz13, |
It 'Should complete "Export-Counter -FileFormat" with available output formats' { | ||
$res = TabExpansion2 -inputScript 'Export-Counter -FileFormat ' -cursorColumn 'Export-Counter -FileFormat '.Length | ||
$res.CompletionMatches.Count | Should Be 3 | ||
$res.CompletionMatches.Foreach{$_.CompletionText -in 'blg', 'csv', 'tsv' | Should Be $true} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to avoid Should Be $true
because it is difficult to understand what went wrong just reading the logs.
In this specific case, I would instead use:
$res.CompletionMatches.CompletionText -join ' ' | Should Be 'blg csv tsv'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be a problem with the element's order.
We can use the auxiliary output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If order is a concern, pipe to sort first. But in this case, if order is not preserved, I would call that a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lzybkr , thank you, I've made the change. Is it appropriate to go ahead and fix the other test cases in this file that use the same pattern? Or is that a separate issue/PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you see the pattern in other files, then maybe a new PR, otherwise this PR is fine.
@@ -65,12 +65,13 @@ public string Path | |||
ValueFromPipelineByPropertyName = false, | |||
HelpMessageBaseName = "GetEventResources")] | |||
[ValidateNotNull] | |||
[ValidateSet("blg", "csv", "tsv")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MiaRomero Yes, please add them to the parameters section as well.
6633eff
to
cfe301f
Compare
Please investigate test failure |
cfe301f
to
45a5520
Compare
I pinged @MiaRomero about updating her profile in order to get the PR merged. |
@TravisEz13 thanks for the link, updated my profile. |