EmilyDirsh / hotwire-shell

Automatically exported from code.google.com/p/hotwire-shell
Other
0 stars 0 forks source link

head and tail for object stream (enhancement) #156

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be great to be able to pipe into head and tail from object streams.

What is the expected output? 

For example, "proc | tail -5" to see the last 5 processes started.

Original issue reported on code.google.com by dmi...@gmail.com on 29 Feb 2008 at 5:54

GoogleCodeExporter commented 9 years ago
The slightly tricky thing about this one is that the option processing system 
won't
let you give arbitrary numbers like -5.  Probably the right thing is to just use
options_passthrough and parse them internally, like how term.py does in the 
latest code.

Original comment by cgwalt...@gmail.com on 29 Feb 2008 at 9:41

GoogleCodeExporter commented 9 years ago
Added head:

hotwire/builtin.py: needs update
    M   hotwire/builtin.py
    A   hotwire/builtins/head.py
Committed r1147

Original comment by cgwalt...@gmail.com on 13 Mar 2008 at 3:29

GoogleCodeExporter commented 9 years ago
Attached is a go at tail.py  It's working for me (once the entry is added to
hotwire/builtin.py )

I started with head.py and added some processing.  Just starting to learn 
python so
there may be better ways of doing it.  Some issues to consider:

* Is there too much overhead appending to the list?  If the count was high this 
might
cause issues ...

* Can the common code (for objects and for files) be put into a separate 
function? 
(I did try, but the yield seemed to stop working, but I've never come across 
yield
before, and haven't got around to reading much about it ...)

All feedback appreciated.

Original comment by dmi...@gmail.com on 4 Apr 2008 at 8:18

Attachments:

GoogleCodeExporter commented 9 years ago
Learnt a bit more python, and given how central lists are I think a few appends 
are
fine here.  And I think the common code around the yield could be moved out, 
but I'm
not sure if it's really worth it for the amount of code involved.

Original comment by dmi...@gmail.com on 7 May 2008 at 4:05

GoogleCodeExporter commented 9 years ago
Added test for head:

modified hotwire/test_command.py
Committed r1297

Original comment by dmi...@gmail.com on 10 Jul 2008 at 4:18

GoogleCodeExporter commented 9 years ago
I've bundled the changes for tail, hotwire/builtin.py and a test into one patch.

Original comment by dmi...@gmail.com on 10 Jul 2008 at 4:27

Attachments: