Skip to content
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

commands: add grep #678

Merged
merged 4 commits into from
Aug 31, 2023

Commits on Aug 31, 2023

  1. WestCommand: expand the subprocess interface

    The WestCommand API for running subprocesses is OK, but
    is missing some useful features; add them now:
    
    - The current recommendation in the subprocess module is
      to use subprocess.run(), so add a helper for doing that
      since it's missing. (The name asymmetry is because
      there is already a WestCommand.run() claimed.)
    
    - Allow subprocess invocations to take any kwargs we want
    
    Signed-off-by: Martí Bolívar <[email protected]>
    mbolivar-ampere committed Aug 31, 2023
    Configuration menu
    Copy the full SHA
    b4234bb View commit details
    Browse the repository at this point in the history
  2. WestCommand: extend print helpers with end kwarg

    This is useful when we want to be able to control whether a newline is
    appended or not. The die() method is intentionally omitted: this is a
    "scream and exit the process" method, and always flushing any
    line-buffered I/O makes sense to enforce in this context.
    
    Signed-off-by: Martí Bolívar <[email protected]>
    mbolivar-ampere committed Aug 31, 2023
    Configuration menu
    Copy the full SHA
    bb1d494 View commit details
    Browse the repository at this point in the history
  3. commands: add grep

    This has been requested various times. I haven't done it because 'west
    forall -c "git grep"' has been a reasonable workaround for me, and I
    never had time or need to think about what an ergonomic alternative
    might look like.
    
    That's changed now and I wanted something that would only print output
    for projects where a result was found, similarly to the way "west
    diff" only prints for projects with nonempty "git diff", etc.
    
    Add a "grep" command that does similar, defaulting to use of "git
    grep" to get the job done. Also support (my favorite) ripgrep and
    plain "grep --recursive". See the GREP_EPILOG variable in the patch
    for detailed usage information.
    
    Signed-off-by: Martí Bolívar <[email protected]>
    mbolivar-ampere committed Aug 31, 2023
    Configuration menu
    Copy the full SHA
    918a8b5 View commit details
    Browse the repository at this point in the history
  4. tests: add basic test for grep command

    Get some minimal coverage.
    
    Signed-off-by: Martí Bolívar <[email protected]>
    mbolivar-ampere committed Aug 31, 2023
    Configuration menu
    Copy the full SHA
    da48280 View commit details
    Browse the repository at this point in the history