hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

Oocli Fantasies #

by why in inspect

I love a few of these concepts Reyn Vlietstra has dropped on the Ruby-Talk list for an object-oriented shell. Gleaned from discussion on the R:O:S mailing list:

  • methods added to filetypes
    • >> somesong.mp3.play
    • >> some.jpg.rotate(90).view
    • >> somefile.extension.defaultopen("/usr/bin/somebinary")
    • >> somefile.extension [which would open it using somebinary]
  • custom global objects
    • >> db.somedatabase.sometable.find_all [active_record could be used here]
    • >> apache.config.port = 81 [Not sure how this would work ? read/write the .conf file ?]
    • >> apache.restart
    • >> samba.config.global.security = user
  • chaining of commands
    • [grep something] | invoke a graphing application which will show the number of ocurrances by filename with a bar chart
    • gimp.applyfilter(gimp.filters.blur) | email.send("blured image","someone@somewhere.com")
  • opengl for the command line:
    • The cli then becomes more of an ide, a combo box could be popped up for command suggestions instead of the usual list of commands which saves space.
    • images could be displayed on the cli iteself
    • a nice graph of the chained commands could be displayed with each command’s projected inputs and outputs for the current fsm [Could be generated by doxygen]

A very sturdy list. I think you’d run into the same problem that Yubnub’s found with pipes. Especially in the case of a gimp-to-email pipe, how does the email know how to translate the incoming string? I imagine metadata will need to accompany strings which are piped. (Ripped from ruby-talk:152684.)

said on 18 Aug 2005 at 11:44

Or named arguments to email.send indicating how to interpret the incoming data. At least that’s how it’s usually dealt with already.

said on 18 Aug 2005 at 12:03

I didn’t entirely buy into this the first time I read it, but I’m starting to…

If you look at these languages in order, Java, Perl, Python, you notice an interesting pattern. At least, you notice this pattern if you are a Lisp hacker. Each one is progressively more like Lisp.

said on 18 Aug 2005 at 12:55

Aww heck, let’s do object-oriented pipes.


class ShellPipe
  def initialize(input=$stdin)
    @input = input
  end
  def to_s ; @input.read ; end
  alias inspect to_s
  def method_missing(*args)
    args.map! {|a| a.to_s}
    ( output_reader, output_writer ) = IO::pipe
    if fork
      output_writer.close
      ShellPipe::new(output_reader)
    else
 output_reader.close
      $stdin.reopen(@input)
      $stdout.reopen(output_writer)
      exec *args
      exit 255
    end
  end
end

class Object
  def method_missing(*args)
    ShellPipe::new.send(*args)
  end
end

Example usage from irb:


irb(main):001:0> ls('-lt').grep('\.rb$').head('-8')
=> shellpipe.rb
minihobix.rb
bumpspark.rb
zook.rb
frink.rb
blah.rb
zubmorfa.rb
kronk.rb

...which is equivalent to ls -lt | grep '\.rb$' | head -8 in the Unix shell.

said on 18 Aug 2005 at 13:09

very interesting. I really like the

somefilename.someextension
pattern, that should be in ruby. Perhaps a module for any object that can be interpreted as a file, ie a byte stream. Then extensions would be methods within this module to cast these objects to an object representing the type?

Another interesting idea would be to add something like distributed lexical scopes a la Obliq. Imagine this from your ruby CLI :

"10.0.0.2".node.user.home.jwatkins.notes.txt.read

or even block migration to compute servers:

node12.compute { ...some heavyweight code... }
said on 18 Aug 2005 at 13:25

Interesting. The syntax is rotated in relation to the shell though: verb obj indirect_obj becomes obj.verb indirect_obj which may feel odd for a shell. It might flow better in the Io language because there are spaces instead of dots between obj and its method.

I think it should be tried to see if it produces something usefully novel. If people see benefit in an Adventure Shell then why not this?

said on 18 Aug 2005 at 17:01

FWIW , my officemate, Bill Wood, likes to use irb for his shell.

said on 19 Aug 2005 at 02:06

Crazy, I was just thinking about this !

What would also be nice, is to use reflection on binaries to get their starting arguments.

said on 19 Aug 2005 at 03:19

Some of this crosses over into Quicksilver: take this, do this to it…

said on 19 Aug 2005 at 05:26

What sounds quite interesting as well is the combination of ‘nix config files & XML (see the ruby-talk link). Some time ago I’ve run across an interesting article on “launchd” (over at www.afp548.com/article.php) that I think already combines ‘nix & XML !

said on 19 Aug 2005 at 19:21

So Microsoft has been touting their new shell called Monad (Hey, better late than never I always say). Now apparently theres a new Ruby-based OOCLI that will be under the GPL … it’s gonna be called…. Gonad.

b’dp ba!

said on 23 Aug 2005 at 16:48

” I imagine metadata will need to accompany strings which are piped.”

Look up “plan9 plumber” on the Googletron sometime.

said on 26 Aug 2005 at 22:38

Someone should mention the wiki

said on 27 Aug 2005 at 01:19

“I imagine metadata will need to accompany strings which are piped.”

The pipe could report what mime-types are available, and allow the data to be read in any applicable format; in this example, email.send would check the mime-types, see that it’s an image, and select the preferred format.

Comments are closed for this entry.