How do I filter by namespace in 'invoke --list | grep'? #419

Closed
Zeioth opened this Issue Jan 14, 2017 · 5 comments

Projects

None yet

2 participants

@Zeioth
Zeioth commented Jan 14, 2017

Hi, if I use

invoke --list | grep meta

This is my output

meta.create_security_group            Creates a EC2
meta.end_stg                          Terminate the stg
meta.update_settings                  Applies changes in

As you can see it shows only 3 words of every description. There's any workaround for this? Thank you.

@Zeioth Zeioth changed the title from How do I filter by namespace using 'invoke --list | grep'? to How do I filter by namespace in 'invoke --list | grep'? Jan 14, 2017
@bitprophet
Member
bitprophet commented Jan 23, 2017 edited

Wow, that's bizarre, but I can reproduce it on my end too. Thanks for the report!

I'm guessing it's to do with the logic around wrapping/truncating to local terminal size, combined with shell pipes masking the running pty (so it's probably using the default parameters which IIRC is 80x24).

What's odd is that in normal usage, if one has a very small terminal, that code is supposed to be either line-wrapping or truncating with an ellipses, neither of which is occurring here. So that may be a corner case bug.

@bitprophet
Member

As an example, here's Invoke's own tasks file, in an 80-col terminal pane:

» inv -l                                                                        
Available tasks:                                                                
                                                                                
  coverage                           Run tests w/ coverage enabled, optionally  
                                     generating HTML & opening it.              
  integration                        Run the integration test suite. May be     
                                     slow!                                      
  sites                              Build both doc sites w/ maxed nitpicking.  
  test                               Run a Spec or Nose-powered internal test   
                                     suite.                                     
  vendorize                          Vendorize Python package ``distribution``  
                                     at version/SHA ``version``.                
  watch_docs                         Watch both doc trees & rebuild them if     
                                     files change.                              
  watch_tests                        Watch source tree and test tree for        
                                     changes, rerunning tests as necessary.     
  docs.browse                        Open build target's index.html in a        
                                     browser (using 'open').                    
  docs.build (docs)                  Build the API docs subsite.                
  docs.clean                         Nuke docs build target directory so next   
                                     build is clean.                            
  docs.tree                                                                     
  release.all (release)              Catchall version-bump/tag/changelog/PyPI   
                                     upload task.                               
  release.build                      Build sdist and/or wheel archives,         
                                     optionally in a temp base directory.       
  release.changelog                  Update changelog with new release entry.   
  release.publish (release.upload)   Publish code to PyPI or index of choice.   
  release.push                       Push tag/changelog/version changes to Git  
                                     origin.                                    
  release.tag                        Create a release tag in git, if one        
                                     doesn't appear to already exist.           
  release.version                    Update stored project version (e.g. a      
                                     ``_version.py``.)                          
  www.browse                         Open build target's index.html in a        
                                     browser (using 'open').                    
  www.build (www)                    Build the main project website.            
  www.clean                          Nuke docs build target directory so next   
                                     build is clean.                            
  www.tree                                                                      

Note how it wraps. (IIRC we're using textwrap or similar.)

On a wider terminal, with a pipe to grep:

» inv -l | grep release                                                       
  release.all (release)              Catchall version-bump/tag/changelog/PyPI 
  release.build                      Build sdist and/or wheel archives,       
  release.changelog                  Update changelog with new release entry. 
  release.publish (release.upload)   Publish code to PyPI or index of choice. 
  release.push                       Push tag/changelog/version changes to Git
  release.tag                        Create a release tag in git, if one      
  release.version                    Update stored project version (e.g. a    
@bitprophet
Member
bitprophet commented Jan 23, 2017 edited

Actually, in my case, it's simply an artifact of the fact that grep doesn't see the wrapped lines! Duh. If one does e.g. inv --list | grep -A1 release this becomes obvious.

So question is, what's happening in @Zeioth's situation? I think I'd need a copy of the offending tasks file in order to truly reproduce. Occam's razor states it's the same thing: the lines are wrapping, and grep is of course unable to tell that wrapped lines "belong" together.

EDIT: I doublechecked and the posted output in the OP is only about 50ish chars wide, so that is still pretty odd (I'd expect truncation at 80, as noted above). Need more info either way.

@Zeioth
Zeioth commented Jan 23, 2017 edited

Thank you for time @bitprophet . You are right. I prepared something you can reproduce, but my output is basically the same than yours.

https://github.com/Zeioth/invoke-testing-grep

Using "-A1" shows all the text, but stacked to about 50 cols. Good enough for me anyway. At least I can read it now!

@bitprophet
Member

Gotcha - so you just had a smaller-than-default terminal window. That'd do it! Thanks for the followup.

@bitprophet bitprophet closed this Jan 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment