-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
[feature] adding select-string -raw #8962
[feature] adding select-string -raw #8962
Conversation
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 is looking good -- have left some comments about changes to make
src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs
Outdated
Show resolved
Hide resolved
@@ -93,6 +107,10 @@ public class MatchInfo | |||
/// <value>The text of the matching line.</value> | |||
public string Line { get; set; } = string.Empty; | |||
|
|||
|
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 remove these newlines
@@ -101,6 +119,9 @@ public class MatchInfo | |||
/// </remarks> | |||
/// </summary> | |||
/// <value>The file name.</value> | |||
|
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 remove these newlines
src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/Select-String.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/Select-String.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/Select-String.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/Select-String.Tests.ps1
Outdated
Show resolved
Hide resolved
This is a student at HackIllinois. @rjmholt and I are working with the students here and are reviewing PRs that they send. |
…chString.cs Co-Authored-By: david-wang24 <42791457+david-wang24@users.noreply.github.com>
src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs
Outdated
Show resolved
Hide resolved
…chString.cs Co-Authored-By: david-wang24 <42791457+david-wang24@users.noreply.github.com>
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.
Lefts a few comments! This is coming along 😄
src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs
Show resolved
Hide resolved
/// </summary> | ||
internal MatchInfo(bool useRaw, bool useColor, int matchIndex, int matchLength) | ||
{ | ||
isRaw = useRaw; |
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.
isRaw = useRaw; | |
_isRaw = useRaw; |
@@ -226,7 +242,15 @@ public string ToString(string directory) | |||
// enable context-tracking. | |||
if (Context == null) | |||
{ | |||
return FormatLine(Line, this.LineNumber, displayPath, EmptyPrefix); | |||
if(isRaw) |
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(isRaw) | |
if(_isRaw) |
@@ -235,14 +259,37 @@ public string ToString(string directory) | |||
int displayLineNumber = this.LineNumber - Context.DisplayPreContext.Length; | |||
foreach (string contextLine in Context.DisplayPreContext) | |||
{ | |||
lines.Add(FormatLine(contextLine, displayLineNumber++, displayPath, ContextPrefix)); | |||
|
|||
if(isRaw) |
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(isRaw) | |
if(_isRaw) |
} | ||
|
||
lines.Add(FormatLine(Line, displayLineNumber++, displayPath, MatchPrefix)); | ||
|
||
if(isRaw) |
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(isRaw) | |
if(_isRaw) |
foreach (string contextLine in Context.DisplayPostContext) | ||
{ | ||
lines.Add(FormatLine(contextLine, displayLineNumber++, displayPath, ContextPrefix)); | ||
if(isRaw) |
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(isRaw) | |
if(_isRaw) |
…Select-String-Convenience [feature] formatting fixes
Sorry for the delay, @david-wang24! This is great work! I do have a thought about the implementation. As we know, in PowerShell, we typically pass around objects everywhere. Into functions, into the pipeline, into variables, everywhere! What The addition of a What your current implementation does is still returning It's still really impressive what you've done so far, but we should look at the problem from a different angle. Does that make sense? Let me know if you're interested in still working on this 😊no rush |
I think we should resist the temptation to add nifty switches. The same thing can be accomplished with
|
@powercode per the discussion in this PR, that would return the complete matching lines, not just the matched strings from each MatchInfo object. |
Actually, @vexx32, @powercode, adding the To recap the rationale:
|
This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days. |
This PR has been automatically closed because it is stale. If you wish to continue working on the PR, please first update the PR, then reopen it. |
PR Summary
Added -Raw switch to select-string for convenience. Issue #7713.
PR Context
Resolves #7713.
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.[feature]
to your commit messages if the change is significant or affects feature tests