8000 Add tab completion for Export-Counter -FileFormat parameter by MiaRomero · Pull Request #3856 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 2 commits into from
Jun 25, 2017

Conversation

MiaRomero
Copy link
Member
@MiaRomero MiaRomero commented May 24, 2017

@@ -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
Copy link
Member

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.

Copy link
Member Author

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)]
Copy link
Collaborator

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@MiaRomero MiaRomero force-pushed the export-counter-tab-completion branch from ff1a99f to 094ba3c Compare May 25, 2017 21:15
@@ -65,12 +65,13 @@ public string Path
ValueFromPipelineByPropertyName = false,
HelpMessageBaseName = "GetEventResources")]
[ValidateNotNull]
[ValidateSet("blg", "csv", "tsv")]
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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" {
@{
Copy link
Member

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.

Copy link
Member Author

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line seems unnecessary.

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated comment

@TravisEz13
Copy link
Member
TravisEz13 commented May 26, 2017

@MiaRomero Please make your membership in the Microsoft Organization public. I sent instructions offline.

#Resolved

Copy link
Member
@TravisEz13 TravisEz13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#resolved

@TravisEz13 TravisEz13 dismissed their stale review May 26, 2017 20:54

Please address @adityapatwardhan 's comments

@TravisEz13
Copy link
Member

@MiaRomero What is the status of this PR?

Copy link
Member
@SteveL-MSFT SteveL-MSFT left a 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

@MiaRomero MiaRomero force-pushed the export-counter-tab-completion branch 2 times, most recently from e3587dc to 6633eff Compare June 1, 2017 18:16
@MiaRomero
Copy link
Member Author

Hi @TravisEz13,
I've addressed @adityapatwardhan's and @SteveL-MSFT's comments regarding the cmdlet and test code. I added a comment asking for clarification on the documentation. Once I have that I can open the appropriate issue.

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}
Copy link
Contributor
@lzybkr lzybkr Jun 1, 2017

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'

Copy link
Collaborator

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

Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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")]
Copy link
Member

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.

@MiaRomero MiaRomero force-pushed the export-counter-tab-completion branch from 6633eff to cfe301f Compare June 2, 2017 17:40
@TravisEz13
Copy link
Member

Please investigate test failure

@MiaRomero MiaRomero force-pushed the export-counter-tab-completion branch from cfe301f to 45a5520 Compare June 7, 2017 00:57
@TravisEz13
Copy link
Member

I pinged @MiaRomero about updating her profile in order to get the PR merged.

@MiaRomero
Copy link
Member Author

@TravisEz13 thanks for the link, updated my profile.

@TravisEz13 TravisEz13 added Blocked blocked on something external to this repo and removed Blocked blocked on something external to this repo labels Jun 25, 2017
@TravisEz13 TravisEz13 merged commit 471f4e8 into PowerShell:master Jun 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0