Skip to content

Conversation

@powercode
Copy link
Collaborator

@powercode powercode commented Aug 8, 2018

PR Summary

Resolves #7278.

Adds a parameter -SkipIndex to the Select-Object cmdlet. The semantics are the opposite of the -Index parameter. All items are passed thru except for the indices specified to -SkipIndex.

( 0..5 | Select-Object -SkipIndex 1,4 ) -join ','

0,2,3,5

PR Checklist

@daxian-dbw daxian-dbw self-assigned this Aug 8, 2018
Copy link
Contributor

@dantraMSFT dantraMSFT left a comment

Choose a reason for hiding this comment

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

Other than a couple of suggestions; LGTM

}

/// <summary>
/// Used to display all objects not at specified index.
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor grammar suggestion:
Used to display all objects not at the specified indices.

}
}

private int _indexOfCurrentObject;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:
To me these field names are confusing. _indexOfCurrentObject implies the object being processed but is actually the index into the array of index filters while _indexCount is the index of the object being processed.

I think it would improve readability if you consider changing these names to something like the following, or some variation:
_currentObjectIndex - the index of the object being processed.
_currentFilterIndex - the index of the active index filter.


It "Select-Object with SkipIndex should work" {
$results = "1", "2", "3" | Select-Object -SkipIndex 0, 2
$results.Count | Should -Be 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Currently we use new syntax:

$results | Should -HaveCount 1

Below too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Didn't know. Fixing.

@iSazonov
Copy link
Collaborator

iSazonov commented Aug 9, 2018

I edited the PR description to auto close the issue.
Keywords https://help.github.com/articles/closing-issues-using-keywords/

@daxian-dbw daxian-dbw merged commit 618d9f3 into PowerShell:master Aug 9, 2018
@iSazonov
Copy link
Collaborator

@powercode Thanks for the enhancement!

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.

Feature: Add Select-Object -SkipIndex parameter

4 participants