From rue at rubyforge.org Thu Sep 1 03:07:44 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 03:07:45 2005 Subject: [Rush-developer] rush/doc CHANGES Message-ID: <200509010707.j8177icR006835@rubyforge.org> Update of /var/cvs/rush/rush/doc In directory rubyforge.org:/tmp/cvs-serv6727/doc Modified Files: CHANGES Log Message: Recommitted the parameter stuff. Reversed parser.rb change, it breaks stuff. Ls.rb did not work, possibly because of ^. Removed unnecessary stuff. Index: CHANGES =================================================================== RCS file: /var/cvs/rush/rush/doc/CHANGES,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CHANGES 31 Aug 2005 08:16:43 -0000 1.6 --- CHANGES 1 Sep 2005 07:07:42 -0000 1.7 *************** *** 33,35 **** Requires ROpt to work! - Docs to commands/command.rb, also see commands/ls.rb for an example. ! - doc/README (updated + took out some fixed bugs). \ No newline at end of file --- 33,41 ---- Requires ROpt to work! - Docs to commands/command.rb, also see commands/ls.rb for an example. ! - doc/README (updated + took out some fixed bugs). ! ! rue, 2005.08.31 02 ! - Recommitted the parameter stuff. ! - Reversed parser.rb change, it breaks stuff. ! - Ls.rb did not work, possibly because of ^ ! - Removed unnecessary stuff. From rue at rubyforge.org Thu Sep 1 03:07:44 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 03:07:45 2005 Subject: [Rush-developer] rush/lib/rush parser.rb Message-ID: <200509010707.j8177icR006837@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush In directory rubyforge.org:/tmp/cvs-serv6727/lib/rush Modified Files: parser.rb Log Message: Recommitted the parameter stuff. Reversed parser.rb change, it breaks stuff. Ls.rb did not work, possibly because of ^. Removed unnecessary stuff. Index: parser.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/parser.rb,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** parser.rb 1 Sep 2005 03:10:00 -0000 1.14 --- parser.rb 1 Sep 2005 07:07:42 -0000 1.15 *************** *** 15,19 **** # x = execute("!#{name} #{args}") ! # x.each_line do |line| # $bw.lines.push(line.delete("\n")) # $bw.cury += 1 --- 15,19 ---- # x = execute("!#{name} #{args}") ! # x.each_line do |line| # $bw.lines.push(line.delete("\n")) # $bw.cury += 1 *************** *** 28,32 **** # Split the line seperated by pipes commands = x.split("|").map{|c| c.strip} ! objects = [] command = nil --- 28,32 ---- # Split the line seperated by pipes commands = x.split("|").map{|c| c.strip} ! objects = [] command = nil *************** *** 34,38 **** begin # Save stdout ! oldout = $stdout # Create the io string --- 34,38 ---- begin # Save stdout ! oldout = $stdout # Create the io string *************** *** 40,55 **** # Set stdout to print to it ! $stdout = is ! r = "" # bad bad bad commands.each do |c| ! begin s = c.split(" ") commandString = s[0] ! rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( " " ) calias = Alias.get(commandString) ! command = Commands.find_respond_to(calias) if calias.strip[0] == 33 #"!" --- 40,56 ---- # Set stdout to print to it ! $stdout = is ! r = "" # bad bad bad commands.each do |c| ! begin s = c.split(" ") commandString = s[0] ! rest = c[commandString.length+1..c.length] ! #rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( " " ) # Breaks stuff calias = Alias.get(commandString) ! command = Commands[calias] if calias.strip[0] == 33 #"!" *************** *** 73,77 **** next end ! if calias.strip[0] == 42 #"*" --- 74,78 ---- next end ! if calias.strip[0] == 42 #"*" *************** *** 88,92 **** next end ! if calias.strip[0] == 94 #"^" --- 89,93 ---- next end ! if calias.strip[0] == 94 #"^" *************** *** 99,104 **** next end ! ! # Could not find the command, try evaluating the ruby string # if it evaluates, set it as the current 'objects' --- 100,105 ---- next end ! ! # Could not find the command, try evaluating the ruby string # if it evaluates, set it as the current 'objects' *************** *** 110,114 **** next rescue LoadError => detail ! return "|#{s}| "+$!.to_s+"\n" rescue SyntaxError => detail return "|#{s}| "+$!.to_s+"\n" --- 111,115 ---- next rescue LoadError => detail ! return "|#{s}| "+$!.to_s+"\n" rescue SyntaxError => detail return "|#{s}| "+$!.to_s+"\n" *************** *** 121,128 **** r = "" command.objects = objects ! evalstr = "command.begin_command" ! evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? ! eval(evalstr) objects = command.objects.clone --- 122,131 ---- r = "" + command = command.new command.objects = objects ! command.begin_command(rest) ! # evalstr = "command.begin_command" ! # evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? ! # eval(evalstr) objects = command.objects.clone *************** *** 130,141 **** rescue DebugException => detail bp("|#{c}| "+detail.message) ! return "|#{c}| "+detail.message rescue => detail return "|#{c}| "+detail.message ! end # end loop end # end foreach part of the pipe ! return r if !r.nil? and r != "" and (command.nil? || command.empty?) return command.print_collection if command != nil --- 133,144 ---- rescue DebugException => detail bp("|#{c}| "+detail.message) ! return "|#{c}| "+detail.message rescue => detail return "|#{c}| "+detail.message ! end # end loop end # end foreach part of the pipe ! return r if !r.nil? and r != "" and (command.nil? || command.empty?) return command.print_collection if command != nil *************** *** 149,153 **** is.rewind ! is.each_line do |line| $bw.lines.push(line.delete("\n")) $bw.cury += 1 --- 152,156 ---- is.rewind ! is.each_line do |line| $bw.lines.push(line.delete("\n")) $bw.cury += 1 From rue at rubyforge.org Thu Sep 1 03:07:44 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 03:07:46 2005 Subject: [Rush-developer] rush/bin rush Message-ID: <200509010707.j8177icR006833@rubyforge.org> Update of /var/cvs/rush/rush/bin In directory rubyforge.org:/tmp/cvs-serv6727/bin Modified Files: rush Log Message: Recommitted the parameter stuff. Reversed parser.rb change, it breaks stuff. Ls.rb did not work, possibly because of ^. Removed unnecessary stuff. Index: rush =================================================================== RCS file: /var/cvs/rush/rush/bin/rush,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** rush 31 Aug 2005 18:31:56 -0000 1.11 --- rush 1 Sep 2005 07:07:41 -0000 1.12 *************** *** 76,80 **** maxy = [Curses::lines] ! # Run environment initializations from ~/.rushrc or the defaults Rush.rush_startup --- 76,80 ---- maxy = [Curses::lines] ! # Run default initializations Rush.rush_startup From rue at rubyforge.org Thu Sep 1 03:07:44 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 03:07:46 2005 Subject: [Rush-developer] rush/lib/rush/commands command.rb commands.rb ls.rb Message-ID: <200509010707.j8177icR006845@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush/commands In directory rubyforge.org:/tmp/cvs-serv6727/lib/rush/commands Modified Files: command.rb commands.rb ls.rb Log Message: Recommitted the parameter stuff. Reversed parser.rb change, it breaks stuff. Ls.rb did not work, possibly because of ^. Removed unnecessary stuff. Index: command.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/command.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** command.rb 31 Aug 2005 18:31:56 -0000 1.7 --- command.rb 1 Sep 2005 07:07:42 -0000 1.8 *************** *** 1,2 **** --- 1,32 ---- + # == Authors + # Please see doc/AUTHORS. + # + # == Copyright + # Copyright (c) 2005 the Authors, all rights reserved. + # + # == Licence + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions + # are met: + # + # - Redistributions of source code must retain the above copyright + # notice, this list of conditions, the following disclaimer and + # attribution to the original authors. + # + # - Redistributions in binary form must reproduce the above copyright + # notice, this list of conditions, the following disclaimer and + # attribution to the original authors in the documentation and/or + # other materials provided with the distribution. + # + # - The names of the authors may not be used to endorse or promote + # products derived from this software without specific prior + # written permission. + # + # == Disclaimer + # This software is provided "as is" and without any express or + # implied warranties, including, without limitation, the implied + # warranties of merchantability and fitness for a particular purpose. + # Authors are not responsible for any damages, direct or indirect. + module Rush *************** *** 6,42 **** class Command attr_accessor :objects # What name should a command respond to def self.respond_to(names) ! meta_def :respond_to do; names; end ! end ! ! def self.parse_options(opts) ! # Redefine this method each time ! return [] unless (opts and not opts.empty?) ! ! # Parse ! result = ROpt.parse(opts.split, *@parse_string) ! ! # Invalid? ! raise ArgumentError.new(usage) unless result ! ! # Dispatch each option's method in turn ! @lookup.each {|(opt, meth)| ! begin ! #self.send(meth, result[opt]) unless result[opt].nil? ! self.method(meth).call ! rescue => details ! puts "Trying to call parm method:"+details.message ! next ! end ! } # lookup.each ! # Give unused args back ! result.args ! end ! ! def self.get_options ! @options end --- 36,47 ---- class Command + class << self; attr_reader :options; end attr_accessor :objects # What name should a command respond to def self.respond_to(names) ! names.to_a.each {|name| Commands.add(name, self)} ! #class << self; define_method(:responds_to) {names}; end ! #meta_def :responds_to do; names; end end *************** *** 69,94 **** # Generate the parse string and a lookup table ! @parse_string, @lookup = [], [] @options.each {|opt| # Parse string ! @parse_string << opt[:s_fmt] if opt[:s_fmt] ! @parse_string << opt[:fmt] if opt[:fmt] # Lookup table ! @lookup << [opt[:key], opt[:method]] ! @lookup << [opt[:name], opt[:method]] } # @options.inject ! end # self.options(opts) - # When something inherits from Command we - # add it to the commands list - def self.inherited(classname) - eval("Commands.add(#{classname}.new)") - super - end - # Write an object to the object stream def writeObject(obj) @objects += obj --- 74,112 ---- # Generate the parse string and a lookup table ! parse_string, lookup = [], [] @options.each {|opt| # Parse string ! parse_string << opt[:s_fmt] if opt[:s_fmt] ! parse_string << opt[:fmt] if opt[:fmt] # Lookup table ! lookup << [opt[:key], opt[:method]] ! lookup << [opt[:name], opt[:method]] } # @options.inject ! # Redefine this method each time ! define_method(:parse_options) {|opts| ! return [] unless (opts and not opts.empty?) + # Parse + result = ROpt.parse(opts.split, *parse_string) + + # Invalid? + raise ArgumentError.new(usage) unless result + + # Dispatch each option's method in turn + lookup.each {|(opt, meth)| + begin + self.send(meth, result[opt]) unless result[opt].nil? + rescue + next + end + } # lookup.each + # Give unused args back + result.args + } # define_method + end # self.options(opts) def writeObject(obj) @objects += obj *************** *** 141,146 **** end ! def initialize ! @objects = [] end --- 159,164 ---- end ! def initialize(objects = []) ! @objects = objects end Index: ls.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/ls.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ls.rb 31 Aug 2005 18:31:56 -0000 1.7 --- ls.rb 1 Sep 2005 07:07:42 -0000 1.8 *************** *** 13,17 **** def begin_command(args=".") super ! @objects = (FsManager.list_children+FsManager.list_items).sort end --- 13,18 ---- def begin_command(args=".") super ! # Not sure what is up with this ! @objects = Dir.entries(File.expand_path(args)) #(FsManager.list_children+FsManager.list_items).sort end Index: commands.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/commands.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** commands.rb 31 Aug 2005 18:31:56 -0000 1.5 --- commands.rb 1 Sep 2005 07:07:42 -0000 1.6 *************** *** 1,2 **** --- 1,32 ---- + # == Authors + # Please see doc/AUTHORS. + # + # == Copyright + # Copyright (c) 2005 the Authors, all rights reserved. + # + # == Licence + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions + # are met: + # + # - Redistributions of source code must retain the above copyright + # notice, this list of conditions, the following disclaimer and + # attribution to the original authors. + # + # - Redistributions in binary form must reproduce the above copyright + # notice, this list of conditions, the following disclaimer and + # attribution to the original authors in the documentation and/or + # other materials provided with the distribution. + # + # - The names of the authors may not be used to endorse or promote + # products derived from this software without specific prior + # written permission. + # + # == Disclaimer + # This software is provided "as is" and without any express or + # implied warranties, including, without limitation, the implied + # warranties of merchantability and fitness for a particular purpose. + # Authors are not responsible for any damages, direct or indirect. + # Required files *************** *** 7,34 **** class Commands ! @@commands = [] def self.get ! @@commands end ! def self.add(command) ! found = false ! ! @@commands.each do |c| ! if c.class == command.class ! found = true ! break ! end ! end ! @@commands.push(command) if !found end def self.find_respond_to(name) ! @@commands.each do |c| ! c.class.respond_to.each{|rt| return c if rt.downcase == name.downcase} ! end ! return nil end end # class Commands --- 37,57 ---- class Commands ! #@@commands = [] ! @commands = {} def self.get ! @commands end ! def self.add(command, command_class) ! @commands[command] = command_class ! end ! def self.[](name) ! @commands[name] end def self.find_respond_to(name) ! [name] end end # class Commands From rue at rubyforge.org Thu Sep 1 03:07:44 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 03:07:46 2005 Subject: [Rush-developer] rush/lib/rush/vfs fs.rb fsftp.rb Message-ID: <200509010707.j8177icR006846@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush/vfs In directory rubyforge.org:/tmp/cvs-serv6727/lib/rush/vfs Modified Files: fs.rb fsftp.rb Log Message: Recommitted the parameter stuff. Reversed parser.rb change, it breaks stuff. Ls.rb did not work, possibly because of ^. Removed unnecessary stuff. Index: fs.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/vfs/fs.rb,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** fs.rb 31 Aug 2005 19:13:31 -0000 1.5 --- fs.rb 1 Sep 2005 07:07:42 -0000 1.6 *************** *** 8,12 **** ev = %Q{ class << self ! def respond_to return "#{names}" end --- 8,12 ---- ev = %Q{ class << self ! def respond_to return "#{names}" end *************** *** 29,51 **** end ! # [returns] an array with all the property names def self.get_properties @properties.map{|m| m[1]} end ! # Should return a list of files on this vfs ! # in the uri ! def self.list_items(uri) ! end ! ! def self.list_children(uri) ! end ! ! def self.navigate(uri,nav) ! end ! ! # Setup the fs ! def self.setup(setupargs) ! end end --- 29,52 ---- end ! # [returns] an array with all the property names def self.get_properties @properties.map{|m| m[1]} end ! # # Should return a list of files on this vfs ! # # in the uri ! # def self.list_items(uri) ! # raise Exception.new('list_items not defined') ! # end ! # ! # def self.list_children(uri) ! # end ! # ! # def self.navigate(uri,nav) ! # end ! # ! # # Setup the fs ! # def self.setup(setupargs) ! # end end Index: fsftp.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/vfs/fsftp.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fsftp.rb 31 Aug 2005 22:34:07 -0000 1.2 --- fsftp.rb 1 Sep 2005 07:07:42 -0000 1.3 *************** *** 7,11 **** # Get the size of the disk ! # apparently there isnt a os independant way of doing this :( add_property "size",:get_size def self.get_size --- 7,11 ---- # Get the size of the disk ! # apparently there isnt a os independant way of doing this :( add_property "size",:get_size def self.get_size *************** *** 27,50 **** puts 'invalid permissions' end ! return @files.sort end ! #parse the terrible output of the list command into something useful def self.parse_list(list) @files = [] @dirs = [] ! re = /^[drwxl\-]{10}\s+\d+\s+\d+\s+\d+\s+\d+\s+[a-zA-Z]{3}\s+\d{2}\s+[\d:]+\s+([\w\-]+)(:? -> ([\w\-]+)|)\s*/ ! puts list.length ! list.each do |y| re.match(y) ! ! if y[0].chr == 'l' || 'd' ! @dirs.push($1) else ! @files.push($1) end end --- 27,50 ---- puts 'invalid permissions' end ! return @files.sort end ! #parse the terrible output of the list command into something useful def self.parse_list(list) @files = [] @dirs = [] ! re = /^[drwxl\-]{10}\s+\d+\s+\d+\s+\d+\s+\d+\s+[a-zA-Z]{3}\s+\d{2}\s+[\d:]+\s+([\w\-]+)(:? -> ([\w\-]+)|)\s*/ ! puts list.length ! list.each do |y| re.match(y) ! ! if 'ld'.include? y[0].chr ! @dirs.push $1 else ! @files.push $1 end end *************** *** 55,59 **** @dirs ||= [] return @dirs.sort ! end def self.complete(l) --- 55,59 ---- @dirs ||= [] return @dirs.sort ! end def self.complete(l) *************** *** 92,96 **** puts 'invalid permissions' end ! begin list = @@ftp.list --- 92,96 ---- puts 'invalid permissions' end ! begin list = @@ftp.list *************** *** 99,103 **** puts 'invalid permissions' end ! return @@ftp.pwd end --- 99,103 ---- puts 'invalid permissions' end ! return @@ftp.pwd end *************** *** 115,123 **** address = setupargs end ! if address.include?('/') address, path = address.split('/', 2) end ! @@ftp = Net::FTP.new(address) @@ftp.passive = true --- 115,123 ---- address = setupargs end ! if address.include?('/') address, path = address.split('/', 2) end ! @@ftp = Net::FTP.new(address) @@ftp.passive = true *************** *** 126,132 **** @@ftp.chdir(path) end ! FsManager.current_path = @@ftp.pwd ! begin list = @@ftp.list --- 126,132 ---- @@ftp.chdir(path) end ! FsManager.current_path = @@ftp.pwd ! begin list = @@ftp.list *************** *** 135,139 **** puts 'invalid permissions' end ! end --- 135,139 ---- puts 'invalid permissions' end ! end From workmin at ccs.neu.edu Thu Sep 1 07:55:00 2005 From: workmin at ccs.neu.edu (Jon Rafkind) Date: Thu Sep 1 07:48:11 2005 Subject: [Rush-developer] rush/lib/rush parser.rb In-Reply-To: <200509010707.j8177icR006837@rubyforge.org> References: <200509010707.j8177icR006837@rubyforge.org> Message-ID: <4316EC14.8020903@ccs.neu.edu> Just wondering what was broken because of expanding the command line options in parser.rb? Command line expansion needs to be done by the shell, as opposed to the commands, so it has to be done at some point in parser.rb. rue@rubyforge.org wrote: >Update of /var/cvs/rush/rush/lib/rush >In directory rubyforge.org:/tmp/cvs-serv6727/lib/rush > >Modified Files: > parser.rb >Log Message: >Recommitted the parameter stuff. Reversed parser.rb change, it breaks stuff. >Ls.rb did not work, possibly because of ^. Removed unnecessary stuff. > > >Index: parser.rb >=================================================================== >RCS file: /var/cvs/rush/rush/lib/rush/parser.rb,v >retrieving revision 1.14 >retrieving revision 1.15 >diff -C2 -d -r1.14 -r1.15 >*** parser.rb 1 Sep 2005 03:10:00 -0000 1.14 >--- parser.rb 1 Sep 2005 07:07:42 -0000 1.15 >*************** >*** 15,19 **** > > # x = execute("!#{name} #{args}") >! # x.each_line do |line| > # $bw.lines.push(line.delete("\n")) > # $bw.cury += 1 >--- 15,19 ---- > > # x = execute("!#{name} #{args}") >! # x.each_line do |line| > # $bw.lines.push(line.delete("\n")) > # $bw.cury += 1 >*************** >*** 28,32 **** > # Split the line seperated by pipes > commands = x.split("|").map{|c| c.strip} >! > objects = [] > command = nil >--- 28,32 ---- > # Split the line seperated by pipes > commands = x.split("|").map{|c| c.strip} >! > objects = [] > command = nil >*************** >*** 34,38 **** > begin > # Save stdout >! oldout = $stdout > > # Create the io string >--- 34,38 ---- > begin > # Save stdout >! oldout = $stdout > > # Create the io string >*************** >*** 40,55 **** > > # Set stdout to print to it >! $stdout = is >! > r = "" # bad bad bad > commands.each do |c| >! > begin > > s = c.split(" ") > commandString = s[0] >! rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( " " ) > calias = Alias.get(commandString) >! command = Commands.find_respond_to(calias) > > if calias.strip[0] == 33 #"!" >--- 40,56 ---- > > # Set stdout to print to it >! $stdout = is >! > r = "" # bad bad bad > commands.each do |c| >! > begin > > s = c.split(" ") > commandString = s[0] >! rest = c[commandString.length+1..c.length] >! #rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( " " ) # Breaks stuff > calias = Alias.get(commandString) >! command = Commands[calias] > > if calias.strip[0] == 33 #"!" >*************** >*** 73,77 **** > next > end >! > if calias.strip[0] == 42 #"*" > >--- 74,78 ---- > next > end >! > if calias.strip[0] == 42 #"*" > >*************** >*** 88,92 **** > next > end >! > if calias.strip[0] == 94 #"^" > >--- 89,93 ---- > next > end >! > if calias.strip[0] == 94 #"^" > >*************** >*** 99,104 **** > next > end >! >! > # Could not find the command, try evaluating the ruby string > # if it evaluates, set it as the current 'objects' >--- 100,105 ---- > next > end >! >! > # Could not find the command, try evaluating the ruby string > # if it evaluates, set it as the current 'objects' >*************** >*** 110,114 **** > next > rescue LoadError => detail >! return "|#{s}| "+$!.to_s+"\n" > rescue SyntaxError => detail > return "|#{s}| "+$!.to_s+"\n" >--- 111,115 ---- > next > rescue LoadError => detail >! return "|#{s}| "+$!.to_s+"\n" > rescue SyntaxError => detail > return "|#{s}| "+$!.to_s+"\n" >*************** >*** 121,128 **** > r = "" > > command.objects = objects >! evalstr = "command.begin_command" >! evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? >! eval(evalstr) > objects = command.objects.clone > >--- 122,131 ---- > r = "" > >+ command = command.new > command.objects = objects >! command.begin_command(rest) >! # evalstr = "command.begin_command" >! # evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? >! # eval(evalstr) > objects = command.objects.clone > >*************** >*** 130,141 **** > rescue DebugException => detail > bp("|#{c}| "+detail.message) >! return "|#{c}| "+detail.message > > rescue => detail > return "|#{c}| "+detail.message >! end # end loop > > end # end foreach part of the pipe >! > return r if !r.nil? and r != "" and (command.nil? || command.empty?) > return command.print_collection if command != nil >--- 133,144 ---- > rescue DebugException => detail > bp("|#{c}| "+detail.message) >! return "|#{c}| "+detail.message > > rescue => detail > return "|#{c}| "+detail.message >! end # end loop > > end # end foreach part of the pipe >! > return r if !r.nil? and r != "" and (command.nil? || command.empty?) > return command.print_collection if command != nil >*************** >*** 149,153 **** > is.rewind > >! is.each_line do |line| > $bw.lines.push(line.delete("\n")) > $bw.cury += 1 >--- 152,156 ---- > is.rewind > >! is.each_line do |line| > $bw.lines.push(line.delete("\n")) > $bw.cury += 1 > >_______________________________________________ >Rush-developer mailing list >Rush-developer@rubyforge.org >http://rubyforge.org/mailman/listinfo/rush-developer > > > > From reynvlietstra at rubyforge.org Thu Sep 1 08:08:03 2005 From: reynvlietstra at rubyforge.org (reynvlietstra@rubyforge.org) Date: Thu Sep 1 08:08:05 2005 Subject: [Rush-developer] rush testclassstuff.rb Message-ID: <200509011208.j81C83cR016050@rubyforge.org> Update of /var/cvs/rush/rush In directory rubyforge.org:/tmp/cvs-serv16000 Added Files: testclassstuff.rb Log Message: THIS IS A TEST TO SHOW HOW I THINK THE CLASS BASED PARAMETER STUFF SHOULD WORK. --- NEW FILE: testclassstuff.rb --- class A def self.respond_to(names) ev = %Q{ class << self def respond_to return "#{names}" end end} instance_eval(ev) end def self.add_property(name,sym) @properties ||= {} @properties[name] = sym end # Returns the value of a defined property def self.get_properties return @properties end # return a property def self.get_property(name) return self.method(@properties[name]).call end end class B < A respond_to "B" add_property "size",:test def self.test "B:test" end end class C < A respond_to "C" add_property "something",:test def self.test "C:test" end end puts B.respond_to puts C.respond_to puts "-- B Properties --" puts B.get_properties puts "-- B Property(size) --" puts B.get_property("size") puts "-- C Properties --" puts C.get_properties puts "-- C Properties --" puts C.get_property("something") From vagabond at rubyforge.org Thu Sep 1 09:52:11 2005 From: vagabond at rubyforge.org (vagabond@rubyforge.org) Date: Thu Sep 1 09:52:11 2005 Subject: [Rush-developer] rush/lib/rush/vfs fstarball.rb Message-ID: <200509011352.j81DqBcR000992@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush/vfs In directory rubyforge.org:/tmp/cvs-serv921 Added Files: fstarball.rb Log Message: Added Beginnings of tarball vfs --- NEW FILE: fstarball.rb --- module Rush class FsTarball < Fs class TarFile def initialize(name) @name = name end end class TarDir attr_accessor :name, :dirs, :files, :parent def initialize(name, parent) @name = name @parent = parent @dirs = [] @files = [] end def add_file(file) @files.push(file) end def add_dir(dir) @dirs.push(dir) end def get_dir(name) @dirs.each do |d| return d if d.name == name end nil end def get_path path = [name] parent = @parent while parent != nil path.push(parent.name) parent = parent.parent end path.reverse.join('/') end end respond_to "tarball" # Get the size of the disk # apparently there isnt a os independant way of doing this :( add_property "size",:get_size def self.get_size return 1234 end # Should return a list of files on this vfs # in the uri def self.list_items(dir) if dir != '.' x = resolve_dir(dir).files else x = @thisdir.files end return x end # List sub directories of pwd def self.list_children(dir) if dir != '.' tdir = resolve_dir(dir) x = tdir.dirs.map{|i| i.name} else x = @thisdir.dirs.map{|i| i.name} tdir = @thisdir end #add . and .. if we're not at the root x = ['.', '..']+x unless tdir == @rootdir return x end def self.complete(l) end def self.resolve_dir(nav) y = @thisdir if nav[0] == '/' y = @rootdir nav = nav[1..-1] end x = nil #split the dirs up, to construct the final path dirs = nav.split('/') dirs.each do |d| if d == '..' if y.parent x = y.parent y = y.parent else x = @rootdir y = @rootdir end elsif dir = y.get_dir(d) #assign y and x in case we loop again y = dir x = dir else puts 'invalid path' end end #default to y if no other path x ||= y return x end # Applies nav to uri, def self.navigate(uri,nav) @thisdir = resolve_dir(nav) return @thisdir.get_path end #parse the files into a crappy object hierarchy def self.parse_files(files, dir) #get the top dirs dirs = files.map do |file| if file.include?('/') x, y = file.split('/', 2) x else nil end end #get the files fs = files.select{|i| !i.include?('/')} #add the files to the current dir fs.each{|f| dir.add_file(f)} #iterate through dirs, creating objects for them and parsing their contents dirs.compact.uniq.each do |d| #create the new dir object and add it to its parent x = TarDir.new(d, dir) dir.add_dir(x) #select the files in this dir, strip the current dir name newfiles = files.select{|i| i[0...d.length] == d and i.include?('/')}.map{|i| i[d.length+1..-1] } parse_files(newfiles, x) end return dir end # Parse the FTP line def self.setup(setupargs) FsManager.current_path = '/' #check if the file exists if File.exist?(setupargs) #get the list from tar files = %x{tar -tf #{setupargs}} #create the rootdir @rootdir = TarDir.new('/', nil) #set the rootdir to here @thisdir = @rootdir #parse the tar output @files = files.chomp.split("\n") parse_files(@files, @rootdir) end end end end From rue at rubyforge.org Thu Sep 1 14:28:54 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 14:28:55 2005 Subject: [Rush-developer] rush command.rb commands.rb ls.rb testclassstuff.rb Message-ID: <200509011828.j81ISscR006205@rubyforge.org> Update of /var/cvs/rush/rush In directory rubyforge.org:/tmp/cvs-serv6160 Removed Files: command.rb commands.rb ls.rb testclassstuff.rb Log Message: Parameter/option stuff again. Minor changes to parser.rb. ls.rb vfs disabled temporarily. --- command.rb DELETED --- --- testclassstuff.rb DELETED --- --- ls.rb DELETED --- --- commands.rb DELETED --- From rue at rubyforge.org Thu Sep 1 14:28:54 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 14:28:55 2005 Subject: [Rush-developer] rush/doc CHANGES Message-ID: <200509011828.j81ISscR006206@rubyforge.org> Update of /var/cvs/rush/rush/doc In directory rubyforge.org:/tmp/cvs-serv6160/doc Modified Files: CHANGES Log Message: Parameter/option stuff again. Minor changes to parser.rb. ls.rb vfs disabled temporarily. Index: CHANGES =================================================================== RCS file: /var/cvs/rush/rush/doc/CHANGES,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CHANGES 1 Sep 2005 07:07:42 -0000 1.7 --- CHANGES 1 Sep 2005 18:28:52 -0000 1.8 *************** *** 35,41 **** - doc/README (updated + took out some fixed bugs). ! rue, 2005.08.31 02 - Recommitted the parameter stuff. - Reversed parser.rb change, it breaks stuff. - Ls.rb did not work, possibly because of ^ - Removed unnecessary stuff. --- 35,46 ---- - doc/README (updated + took out some fixed bugs). ! rue, 2005.08.31 02: - Recommitted the parameter stuff. - Reversed parser.rb change, it breaks stuff. - Ls.rb did not work, possibly because of ^ - Removed unnecessary stuff. + + rue, 2005.09.01 01: + - Parameter/option stuff again. + - Minor changes to parser.rb. + - ls.rb vfs disabled temporarily. From rue at rubyforge.org Thu Sep 1 14:28:54 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 14:28:55 2005 Subject: [Rush-developer] rush/lib/rush parser.rb Message-ID: <200509011828.j81ISscR006210@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush In directory rubyforge.org:/tmp/cvs-serv6160/lib/rush Modified Files: parser.rb Log Message: Parameter/option stuff again. Minor changes to parser.rb. ls.rb vfs disabled temporarily. Index: parser.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/parser.rb,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** parser.rb 1 Sep 2005 07:07:42 -0000 1.15 --- parser.rb 1 Sep 2005 18:28:52 -0000 1.16 *************** *** 49,53 **** s = c.split(" ") commandString = s[0] ! rest = c[commandString.length+1..c.length] #rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( " " ) # Breaks stuff calias = Alias.get(commandString) --- 49,53 ---- s = c.split(" ") commandString = s[0] ! rest = c[commandString.length+1..c.length] || '' #rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( " " ) # Breaks stuff calias = Alias.get(commandString) *************** *** 124,128 **** command = command.new command.objects = objects ! command.begin_command(rest) # evalstr = "command.begin_command" # evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? --- 124,133 ---- command = command.new command.objects = objects ! ! #if rest and not rest.empty? ! command.begin_command(rest) ! #else ! # command.begin_command ! #end # evalstr = "command.begin_command" # evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? From rue at rubyforge.org Thu Sep 1 14:28:54 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 14:28:56 2005 Subject: [Rush-developer] rush/lib/rush/commands ls.rb Message-ID: <200509011828.j81ISscR006214@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush/commands In directory rubyforge.org:/tmp/cvs-serv6160/lib/rush/commands Modified Files: ls.rb Log Message: Parameter/option stuff again. Minor changes to parser.rb. ls.rb vfs disabled temporarily. Index: ls.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/ls.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ls.rb 1 Sep 2005 07:07:42 -0000 1.8 --- ls.rb 1 Sep 2005 18:28:52 -0000 1.9 *************** *** 5,11 **** respond_to "ls" ! option :name => 'help', :key => 'h', :method => :help, :desc => "Displays a help." ! def self.help(*args) puts "Shows the contents of a directory. Usage: ls [path]" end --- 5,11 ---- respond_to "ls" ! #option :name => 'help', :key => 'h', :method => :help, :desc => "Displays a help." ! def help(*args) puts "Shows the contents of a directory. Usage: ls [path]" end From workmin at ccs.neu.edu Thu Sep 1 19:32:35 2005 From: workmin at ccs.neu.edu (Jon Rafkind) Date: Thu Sep 1 19:25:44 2005 Subject: [Rush-developer] rush/lib/rush parser.rb In-Reply-To: <43178779.10008@magical-cat.org> References: <200509010707.j8177icR006837@rubyforge.org> <4316EC14.8020903@ccs.neu.edu> <43178779.10008@magical-cat.org> Message-ID: <43178F93.2020505@ccs.neu.edu> ok, you're right. cc'ing the list.. ES wrote: > Jon Rafkind wrote: > >> Just wondering what was broken because of expanding the command line >> options in parser.rb? Command line expansion needs to be done by the >> shell, as opposed to the commands, so it has to be done at some point >> in parser.rb. > > > It messes up argument handling. Say I pass -h to a command; .expand_path > transforms it to /path/to/current/dir/-h :/ Also, in some instances the > user does not expect to see a full path, which .expand_path always does. > > I think the VFS is probably a better place to do the extension, take > a look if you can see about implementing it there. > > E > >> rue@rubyforge.org wrote: >> >>> Update of /var/cvs/rush/rush/lib/rush >>> In directory rubyforge.org:/tmp/cvs-serv6727/lib/rush >>> >>> Modified Files: >>> parser.rb Log Message: >>> Recommitted the parameter stuff. Reversed parser.rb change, it >>> breaks stuff. >>> Ls.rb did not work, possibly because of ^. Removed unnecessary stuff. >>> >>> >>> Index: parser.rb >>> =================================================================== >>> RCS file: /var/cvs/rush/rush/lib/rush/parser.rb,v >>> retrieving revision 1.14 >>> retrieving revision 1.15 >>> diff -C2 -d -r1.14 -r1.15 >>> *** parser.rb 1 Sep 2005 03:10:00 -0000 1.14 >>> --- parser.rb 1 Sep 2005 07:07:42 -0000 1.15 >>> *************** >>> *** 15,19 **** >>> >>> # x = execute("!#{name} #{args}") >>> ! # x.each_line do |line| # >>> $bw.lines.push(line.delete("\n")) >>> # $bw.cury += 1 >>> --- 15,19 ---- >>> >>> # x = execute("!#{name} #{args}") >>> ! # x.each_line do |line| >>> # $bw.lines.push(line.delete("\n")) >>> # $bw.cury += 1 >>> *************** >>> *** 28,32 **** >>> # Split the line seperated by pipes >>> commands = x.split("|").map{|c| c.strip} >>> ! objects = [] >>> command = nil >>> --- 28,32 ---- >>> # Split the line seperated by pipes >>> commands = x.split("|").map{|c| c.strip} >>> ! objects = [] >>> command = nil >>> *************** >>> *** 34,38 **** >>> begin >>> # Save stdout >>> ! oldout = $stdout # Create the io string >>> --- 34,38 ---- >>> begin >>> # Save stdout >>> ! oldout = $stdout >>> >>> # Create the io string >>> *************** >>> *** 40,55 **** >>> >>> # Set stdout to print to it >>> ! $stdout = is ! r = "" # bad bad bad >>> commands.each do |c| >>> ! begin >>> >>> s = c.split(" ") >>> commandString = s[0] >>> ! rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( " >>> " ) >>> calias = Alias.get(commandString) >>> ! command = Commands.find_respond_to(calias) >>> >>> if calias.strip[0] == 33 #"!" >>> --- 40,56 ---- >>> >>> # Set stdout to print to it >>> ! $stdout = is >>> ! r = "" # bad bad bad >>> commands.each do |c| >>> ! begin >>> >>> s = c.split(" ") >>> commandString = s[0] >>> ! rest = c[commandString.length+1..c.length] >>> ! #rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( >>> " " ) # Breaks stuff >>> calias = Alias.get(commandString) >>> ! command = Commands[calias] >>> >>> if calias.strip[0] == 33 #"!" >>> *************** >>> *** 73,77 **** >>> next >>> end >>> ! if calias.strip[0] == 42 #"*" >>> >>> --- 74,78 ---- >>> next >>> end >>> ! if calias.strip[0] == 42 #"*" >>> >>> *************** >>> *** 88,92 **** >>> next >>> end >>> ! if calias.strip[0] == 94 #"^" >>> >>> --- 89,93 ---- >>> next >>> end >>> ! if calias.strip[0] == 94 #"^" >>> >>> *************** >>> *** 99,104 **** >>> next >>> end >>> ! ! # Could not find the command, try evaluating >>> the ruby string >>> # if it evaluates, set it as the current 'objects' >>> --- 100,105 ---- >>> next >>> end >>> ! ! # Could not find the command, try evaluating the ruby string >>> # if it evaluates, set it as the current 'objects' >>> *************** >>> *** 110,114 **** >>> next >>> rescue LoadError => detail >>> ! return "|#{s}| "+$!.to_s+"\n" rescue >>> SyntaxError => detail >>> return "|#{s}| "+$!.to_s+"\n" >>> --- 111,115 ---- >>> next >>> rescue LoadError => detail >>> ! return "|#{s}| "+$!.to_s+"\n" >>> rescue SyntaxError => detail >>> return "|#{s}| "+$!.to_s+"\n" >>> *************** >>> *** 121,128 **** >>> r = "" >>> >>> command.objects = objects >>> ! evalstr = "command.begin_command" >>> ! evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? >>> ! eval(evalstr) >>> objects = command.objects.clone >>> >>> --- 122,131 ---- >>> r = "" >>> >>> + command = command.new >>> command.objects = objects >>> ! command.begin_command(rest) >>> ! # evalstr = "command.begin_command" >>> ! # evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? >>> ! # eval(evalstr) >>> objects = command.objects.clone >>> >>> *************** >>> *** 130,141 **** >>> rescue DebugException => detail >>> bp("|#{c}| "+detail.message) >>> ! return "|#{c}| "+detail.message rescue => detail >>> return "|#{c}| "+detail.message >>> ! end # end loop end # end foreach part of the pipe >>> ! return r if !r.nil? and r != "" and (command.nil? || >>> command.empty?) >>> return command.print_collection if command != nil >>> --- 133,144 ---- >>> rescue DebugException => detail >>> bp("|#{c}| "+detail.message) >>> ! return "|#{c}| "+detail.message >>> >>> rescue => detail >>> return "|#{c}| "+detail.message >>> ! end # end loop >>> >>> end # end foreach part of the pipe >>> ! return r if !r.nil? and r != "" and (command.nil? || >>> command.empty?) >>> return command.print_collection if command != nil >>> *************** >>> *** 149,153 **** >>> is.rewind >>> >>> ! is.each_line do |line| $bw.lines.push(line.delete("\n")) >>> $bw.cury += 1 >>> --- 152,156 ---- >>> is.rewind >>> >>> ! is.each_line do |line| >>> $bw.lines.push(line.delete("\n")) >>> $bw.cury += 1 >>> >>> _______________________________________________ >>> Rush-developer mailing list >>> Rush-developer@rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rush-developer >>> >>> >>> >>> >> _______________________________________________ >> Rush-developer mailing list >> Rush-developer@rubyforge.org >> http://rubyforge.org/mailman/listinfo/rush-developer >> >> >> > > > From rue at rubyforge.org Thu Sep 1 23:27:18 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 23:27:19 2005 Subject: [Rush-developer] rush/bundles - New directory Message-ID: <200509020327.j823RIcR012558@rubyforge.org> Update of /var/cvs/rush/rush/bundles In directory rubyforge.org:/tmp/cvs-serv12547/bundles Log Message: Directory /var/cvs/rush/rush/bundles added to the repository From rue at rubyforge.org Thu Sep 1 23:27:35 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 23:27:37 2005 Subject: [Rush-developer] rush/bundles/options - New directory Message-ID: <200509020327.j823RZcR012589@rubyforge.org> Update of /var/cvs/rush/rush/bundles/options In directory rubyforge.org:/tmp/cvs-serv12585/bundles/options Log Message: Directory /var/cvs/rush/rush/bundles/options added to the repository From rue at rubyforge.org Thu Sep 1 23:28:36 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 23:28:37 2005 Subject: [Rush-developer] rush/bundles/options/lib - New directory Message-ID: <200509020328.j823SacR012685@rubyforge.org> Update of /var/cvs/rush/rush/bundles/options/lib In directory rubyforge.org:/tmp/cvs-serv12677/bundles/options/lib Log Message: Directory /var/cvs/rush/rush/bundles/options/lib added to the repository From rue at rubyforge.org Thu Sep 1 23:29:08 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 23:29:10 2005 Subject: [Rush-developer] rush/bundles/options/doc - New directory Message-ID: <200509020329.j823T8cR012744@rubyforge.org> Update of /var/cvs/rush/rush/bundles/options/doc In directory rubyforge.org:/tmp/cvs-serv12738/bundles/options/doc Log Message: Directory /var/cvs/rush/rush/bundles/options/doc added to the repository From rue at rubyforge.org Thu Sep 1 23:44:03 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 23:44:05 2005 Subject: [Rush-developer] rush/bundles options--0.0.1.tar.gz Message-ID: <200509020344.j823i3cR013968@rubyforge.org> Update of /var/cvs/rush/rush/bundles In directory rubyforge.org:/tmp/cvs-serv13914/bundles Added Files: options--0.0.1.tar.gz Log Message: Added bundles/ for including required packages and added options--0.0.1 to it. --- NEW FILE: options--0.0.1.tar.gz --- (This appears to be a binary file; contents omitted.) From rue at rubyforge.org Thu Sep 1 23:44:03 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Thu Sep 1 23:44:05 2005 Subject: [Rush-developer] rush/doc CHANGES README Message-ID: <200509020344.j823i3cR013969@rubyforge.org> Update of /var/cvs/rush/rush/doc In directory rubyforge.org:/tmp/cvs-serv13914/doc Modified Files: CHANGES README Log Message: Added bundles/ for including required packages and added options--0.0.1 to it. Index: README =================================================================== RCS file: /var/cvs/rush/rush/doc/README,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** README 31 Aug 2005 08:16:43 -0000 1.5 --- README 2 Sep 2005 03:44:01 -0000 1.6 *************** *** 3,11 **** == Requirements * Ruby 1.8.2 - http://www.ruby-lang.org * Updated Curses module - http://reyn.co.za/curses.so * ruby-breakpoint - http://ruby-breakpoint.rubyforge.org/ * open4 - http://www.codeforpeople.com/lib/ruby/open4/ - * ROpt - http://raa.ruby-lang.org/project/ropt/ * rubygems - http://raa.ruby-lang.org/project/rubygems/ --- 3,17 ---- == Requirements + === Bundled + Under bundles/, you will find some of the required packages: + * options - http://www.magical-cat.org/projects/options + + Each should contain instructions on installation. + + === Unbundled * Ruby 1.8.2 - http://www.ruby-lang.org * Updated Curses module - http://reyn.co.za/curses.so * ruby-breakpoint - http://ruby-breakpoint.rubyforge.org/ * open4 - http://www.codeforpeople.com/lib/ruby/open4/ * rubygems - http://raa.ruby-lang.org/project/rubygems/ Index: CHANGES =================================================================== RCS file: /var/cvs/rush/rush/doc/CHANGES,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CHANGES 1 Sep 2005 18:28:52 -0000 1.8 --- CHANGES 2 Sep 2005 03:44:01 -0000 1.9 *************** *** 45,46 **** --- 45,50 ---- - Minor changes to parser.rb. - ls.rb vfs disabled temporarily. + + rue, 2005.09.01 02: + - bundles/ for required packages shipped with rush. + - bundles/options--0.0.1 for option parsing. Not in rush itsef yet! From rue at rubyforge.org Fri Sep 2 00:56:26 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Fri Sep 2 00:56:28 2005 Subject: [Rush-developer] rush/doc CHANGES Message-ID: <200509020456.j824uQcR005826@rubyforge.org> Update of /var/cvs/rush/rush/doc In directory rubyforge.org:/tmp/cvs-serv5667/doc Modified Files: CHANGES Log Message: New option parser implemented and working OK. Index: CHANGES =================================================================== RCS file: /var/cvs/rush/rush/doc/CHANGES,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CHANGES 2 Sep 2005 03:44:01 -0000 1.9 --- CHANGES 2 Sep 2005 04:56:24 -0000 1.10 *************** *** 49,50 **** --- 49,53 ---- - bundles/ for required packages shipped with rush. - bundles/options--0.0.1 for option parsing. Not in rush itsef yet! + + rue, 2005.09.01 03: + - Moved to new option parser, everything working smoothly-ish. From rue at rubyforge.org Fri Sep 2 00:56:26 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Fri Sep 2 00:56:28 2005 Subject: [Rush-developer] rush/lib/rush/commands command.rb ls.rb Message-ID: <200509020456.j824uQcR005828@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush/commands In directory rubyforge.org:/tmp/cvs-serv5667/lib/rush/commands Modified Files: command.rb ls.rb Log Message: New option parser implemented and working OK. Index: command.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/command.rb,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** command.rb 1 Sep 2005 07:07:42 -0000 1.8 --- command.rb 2 Sep 2005 04:56:24 -0000 1.9 *************** *** 31,35 **** module Rush ! require 'ropt' require 'yaml' --- 31,35 ---- module Rush ! require 'options' require 'yaml' *************** *** 51,54 **** --- 51,58 ---- # and a long option name must be specified. # + # Creates an instance method, #parse_options, using information + # gathered from this method. It takes a String of arguments and + # returns any non-option arguments. + # # [Takes] - option, a Hash comprising the option desired. # - :name is the long name of the option, e.g. help. *************** *** 58,109 **** # [Returns] nothing but does create an instance method. def self.option(option) ! # Store the options ! @options ||= [] ! ! # Normalize the new option data ! option[:fmt], option[:key_fmt] = if option[:arg] == :yes ! ["#{option[:key]}:", "#{option[:name]}:"] ! elsif option[:arg] == :many ! ["#{option[:key]}::", "#{option[:name]}::"] ! else ! [option[:key], option[:name]] ! end ! ! # Tack it on with the rest for easier processing ! @options << option ! # Generate the parse string and a lookup table ! parse_string, lookup = [], [] ! @options.each {|opt| ! # Parse string ! parse_string << opt[:s_fmt] if opt[:s_fmt] ! parse_string << opt[:fmt] if opt[:fmt] ! # Lookup table ! lookup << [opt[:key], opt[:method]] ! lookup << [opt[:name], opt[:method]] ! } # @options.inject ! # Redefine this method each time define_method(:parse_options) {|opts| - return [] unless (opts and not opts.empty?) - # Parse ! result = ROpt.parse(opts.split, *parse_string) ! ! # Invalid? ! raise ArgumentError.new(usage) unless result # Dispatch each option's method in turn ! lookup.each {|(opt, meth)| ! begin ! self.send(meth, result[opt]) unless result[opt].nil? ! rescue ! next ! end } # lookup.each ! # Give unused args back ! result.args ! } # define_method end # self.options(opts) --- 62,90 ---- # [Returns] nothing but does create an instance method. def self.option(option) ! @o ||= Options.new ! @options ||= [] ! @options << option ! # Configure the parser ! @o.configure({option[:name] => {:args => option[:args]}, ! option[:key] => {:args => option[:args]}}) ! # Generate a lookup table ! lookup = @options.inject({}) {|l, opt| l[opt[:name]] = l[opt[:key]] = opt[:method]; l} ! parser = @o # For closure ! # Define a method to properly respond (redefined each time). define_method(:parse_options) {|opts| # Parse ! result = parser.parse opts # Dispatch each option's method in turn ! lookup.each {|key, method| ! next unless args = result[key] ! self.send(method, args) } # lookup.each ! # Return all non-option args ! result[:args] ! } # define_method(:parse_options) end # self.options(opts) Index: ls.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/ls.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ls.rb 1 Sep 2005 18:28:52 -0000 1.9 --- ls.rb 2 Sep 2005 04:56:24 -0000 1.10 *************** *** 5,9 **** respond_to "ls" ! #option :name => 'help', :key => 'h', :method => :help, :desc => "Displays a help." def help(*args) --- 5,9 ---- respond_to "ls" ! option :name => 'help', :key => 'h', :method => :help, :desc => "Displays a help." def help(*args) *************** *** 11,18 **** end ! def begin_command(args=".") super # Not sure what is up with this ! @objects = Dir.entries(File.expand_path(args)) #(FsManager.list_children+FsManager.list_items).sort end --- 11,22 ---- end ! def begin_command(args = '.') super + Dir.entries(File.expand_path(args)) + # args = parse_options(args) + # dir = args.last || '.' + # @objects = Dir.entries(File.expand_path(dir)) # Not sure what is up with this ! #(FsManager.list_children+FsManager.list_items).sort end From rue at rubyforge.org Fri Sep 2 04:00:47 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Fri Sep 2 04:00:51 2005 Subject: [Rush-developer] rush/lib/rush parser.rb Message-ID: <200509020800.j8280lcR010797@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush In directory rubyforge.org:/tmp/cvs-serv10605/lib/rush Modified Files: parser.rb Log Message: Fixed parser.rb and ls.rb. Again. Index: parser.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/parser.rb,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** parser.rb 1 Sep 2005 18:28:52 -0000 1.16 --- parser.rb 2 Sep 2005 08:00:43 -0000 1.17 *************** *** 1,3 **** ! module Rush require 'stringio' --- 1,3 ---- ! module Rush require 'stringio' *************** *** 25,28 **** --- 25,35 ---- #end + + # ls -la => ls.execute('-la') + # ls -la /etc => ls.execute('-la /etc') + # ls -la | selector | cd => ls.pipe('-la') {|lsitem| selector.pipe(lsitem) {|selitem| cd.execute(selitem)}} + # cat foo | grep 'bar' => cat.pipe('foo') {|catitem| grep.execute('bar')} + + def self.execute(x) # Split the line seperated by pipes *************** *** 49,53 **** s = c.split(" ") commandString = s[0] ! rest = c[commandString.length+1..c.length] || '' #rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( " " ) # Breaks stuff calias = Alias.get(commandString) --- 56,60 ---- s = c.split(" ") commandString = s[0] ! rest = c[commandString.length+1..c.length] #rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( " " ) # Breaks stuff calias = Alias.get(commandString) *************** *** 125,133 **** command.objects = objects ! #if rest and not rest.empty? command.begin_command(rest) ! #else ! # command.begin_command ! #end # evalstr = "command.begin_command" # evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? --- 132,140 ---- command.objects = objects ! if rest and not rest.empty? command.begin_command(rest) ! else ! command.begin_command ! end # evalstr = "command.begin_command" # evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? From rue at rubyforge.org Fri Sep 2 04:00:47 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Fri Sep 2 04:00:51 2005 Subject: [Rush-developer] rush/lib/rush/commands ls.rb Message-ID: <200509020800.j8280lcR010799@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush/commands In directory rubyforge.org:/tmp/cvs-serv10605/lib/rush/commands Modified Files: ls.rb Log Message: Fixed parser.rb and ls.rb. Again. Index: ls.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/ls.rb,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ls.rb 2 Sep 2005 04:56:24 -0000 1.10 --- ls.rb 2 Sep 2005 08:00:45 -0000 1.11 *************** *** 13,17 **** def begin_command(args = '.') super ! Dir.entries(File.expand_path(args)) # args = parse_options(args) # dir = args.last || '.' --- 13,17 ---- def begin_command(args = '.') super ! @objects = Dir.entries(File.expand_path(args)) # args = parse_options(args) # dir = args.last || '.' From rue at rubyforge.org Sun Sep 18 19:53:57 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Sun, 18 Sep 2005 23:53:57 +0000 Subject: [Rush-developer] rush/bin rush Message-ID: <200509182353.j8INrv05019813@rubyforge.org> Update of /var/cvs/rush/rush/bin In directory rubyforge.org:/tmp/cvs-serv19749/bin Modified Files: rush Log Message: Huge update. - default_config.rb just executes its contents rather than defining methods to be called to do it. - default_config does define dummies on_startup and on_shutdown. These should be overridden in ~/.rushrc - bin/rush just #requires default_config - Default ruby-mode prompt in default_config.rb. - Key#execute raises NotImplementedError instead of Exception. - Removed handling of Parser.execute from keys/enter.rb - keys/ruby_mode.rb to implement ^R ruby-mode control. - Completely rewrote parser.rb to support the new piping and ruby-mode. - Executing & 'remembering' *arbitrary Ruby* from the line supported. - commands/special_commands.rb to implement special processing for types of piped sections. - command.rb rewritten to facilitate the piping. - $env[:rubyreturn] decides how Ruby statements are output. If it is true, each statement is followed by # => , somewhat like irb. By default not set in which case the return value is swallowed. - Rudimentary support for pushing input to system commands: 'foo' | !grep 'foo' - $env[:debug] to control general debug info output. - All Commands adhere to the new syntax. - commands/print.rb and toglobal.rb are being deprecated as useless. Index: rush =================================================================== RCS file: /var/cvs/rush/rush/bin/rush,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** rush 1 Sep 2005 07:07:41 -0000 1.12 --- rush 18 Sep 2005 23:53:55 -0000 1.13 *************** *** 41,51 **** # Base Dependancies ! require "rush/general.rb" # Needs to be first require "rush/parser.rb" - require "rush/default_config.rb" require "rush/exceptions.rb" - require "rush/metaid.rb" require "rush/alias.rb" require "rush/history.rb" # Virtual file system require "rush/vfs/fs.rb" --- 41,55 ---- # Base Dependancies ! # Do not change the order ! require "rush/metaid.rb" ! require "rush/general.rb" require "rush/parser.rb" require "rush/exceptions.rb" require "rush/alias.rb" require "rush/history.rb" + + # Run default initializations + require 'rush/default_config.rb' + # Virtual file system require "rush/vfs/fs.rb" *************** *** 77,88 **** # Run default initializations ! Rush.rush_startup # Load user config if there is one begin Rush.load_script_file "#{ENV["HOME"]}/.rushrc" ! Rush.rush_startup # run it's startup to add to the config ! Rush.rush_init_curses ! rescue LoadError # Using default configs end --- 81,92 ---- # Run default initializations ! #require 'rush/default_config.rb' # Load user config if there is one begin Rush.load_script_file "#{ENV["HOME"]}/.rushrc" ! Rush.on_startup # run it's startup to add to the config ! #Rush.rush_init_curses ! #rescue LoadError # Using default configs end *************** *** 99,103 **** $bw.run do |char| ! # Locate a special keybinding key = Rush::Keys[char] --- 103,107 ---- $bw.run do |char| ! # Locate special keybindings (Enter, ^C and anything else) key = Rush::Keys[char] *************** *** 132,136 **** ensure Rush.curses_stop ! Rush.rush_shutdown # User-definable cleanup end end # if __FILE__ == $0 --- 136,140 ---- ensure Rush.curses_stop ! Rush.on_shutdown # User-definable cleanup end end # if __FILE__ == $0 From rue at rubyforge.org Sun Sep 18 19:53:57 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Sun, 18 Sep 2005 23:53:57 +0000 Subject: [Rush-developer] rush/doc CHANGES Message-ID: <200509182353.j8INrv05019815@rubyforge.org> Update of /var/cvs/rush/rush/doc In directory rubyforge.org:/tmp/cvs-serv19749/doc Modified Files: CHANGES Log Message: Huge update. - default_config.rb just executes its contents rather than defining methods to be called to do it. - default_config does define dummies on_startup and on_shutdown. These should be overridden in ~/.rushrc - bin/rush just #requires default_config - Default ruby-mode prompt in default_config.rb. - Key#execute raises NotImplementedError instead of Exception. - Removed handling of Parser.execute from keys/enter.rb - keys/ruby_mode.rb to implement ^R ruby-mode control. - Completely rewrote parser.rb to support the new piping and ruby-mode. - Executing & 'remembering' *arbitrary Ruby* from the line supported. - commands/special_commands.rb to implement special processing for types of piped sections. - command.rb rewritten to facilitate the piping. - $env[:rubyreturn] decides how Ruby statements are output. If it is true, each statement is followed by # => , somewhat like irb. By default not set in which case the return value is swallowed. - Rudimentary support for pushing input to system commands: 'foo' | !grep 'foo' - $env[:debug] to control general debug info output. - All Commands adhere to the new syntax. - commands/print.rb and toglobal.rb are being deprecated as useless. Index: CHANGES =================================================================== RCS file: /var/cvs/rush/rush/doc/CHANGES,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CHANGES 2 Sep 2005 04:56:24 -0000 1.10 --- CHANGES 18 Sep 2005 23:53:55 -0000 1.11 *************** *** 52,53 **** --- 52,79 ---- rue, 2005.09.01 03: - Moved to new option parser, everything working smoothly-ish. + + rue, 2005.09.02 01: + - Fixed parser.rb and ls.rb. Again. + + rue, 2005.09.xx 01: + - default_config.rb just executes its contents rather than defining + methods to be called to do it. + - default_config does define dummies on_startup and on_shutdown. These should be + overridden in ~/.rushrc + - bin/rush just #requires default_config + - Default ruby-mode prompt in default_config.rb. + - Key#execute raises NotImplementedError instead of Exception. + - Removed handling of Parser.execute from keys/enter.rb + - keys/ruby_mode.rb to implement ^R ruby-mode control. + - Completely rewrote parser.rb to support the new piping and ruby-mode. + - Executing & 'remembering' *arbitrary Ruby* from the line supported. + - commands/special_commands.rb to implement special processing + for types of piped sections. + - command.rb rewritten to facilitate the piping. + - $env[:rubyreturn] decides how Ruby statements are output. If it is + true, each statement is followed by # => , somewhat like + irb. By default not set in which case the return value is swallowed. + - Rudimentary support for pushing input to system commands: 'foo' | !grep 'foo' + - $env[:debug] to control general debug info output. + - All Commands adhere to the new syntax. + - commands/print.rb and toglobal.rb are being deprecated as useless. From rue at rubyforge.org Sun Sep 18 19:53:57 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Sun, 18 Sep 2005 23:53:57 +0000 Subject: [Rush-developer] rush/lib/rush alias.rb default_config.rb general.rb parser.rb Message-ID: <200509182353.j8INrv05019821@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush In directory rubyforge.org:/tmp/cvs-serv19749/lib/rush Modified Files: alias.rb default_config.rb general.rb parser.rb Log Message: Huge update. - default_config.rb just executes its contents rather than defining methods to be called to do it. - default_config does define dummies on_startup and on_shutdown. These should be overridden in ~/.rushrc - bin/rush just #requires default_config - Default ruby-mode prompt in default_config.rb. - Key#execute raises NotImplementedError instead of Exception. - Removed handling of Parser.execute from keys/enter.rb - keys/ruby_mode.rb to implement ^R ruby-mode control. - Completely rewrote parser.rb to support the new piping and ruby-mode. - Executing & 'remembering' *arbitrary Ruby* from the line supported. - commands/special_commands.rb to implement special processing for types of piped sections. - command.rb rewritten to facilitate the piping. - $env[:rubyreturn] decides how Ruby statements are output. If it is true, each statement is followed by # => , somewhat like irb. By default not set in which case the return value is swallowed. - Rudimentary support for pushing input to system commands: 'foo' | !grep 'foo' - $env[:debug] to control general debug info output. - All Commands adhere to the new syntax. - commands/print.rb and toglobal.rb are being deprecated as useless. Index: parser.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/parser.rb,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** parser.rb 2 Sep 2005 08:00:43 -0000 1.17 --- parser.rb 18 Sep 2005 23:53:55 -0000 1.18 *************** *** 1,176 **** ! module Rush require 'stringio' ! class Parser ! ! def initialize ! end ! ! #def self.method_missing(id, *args) ! # name = id.id2name ! # args = args.join(" ") ! # ENV["PATH"].split(":").each do |dir| ! # if File.exists?(File.join(dir, name)) ! ! # x = execute("!#{name} #{args}") ! # x.each_line do |line| ! # $bw.lines.push(line.delete("\n")) ! # $bw.cury += 1 ! # end ! # return ! # end ! # end ! # execute("puts \"ruSH doesnt know what to do with that\"") ! #end ! ! ! # ls -la => ls.execute('-la') ! # ls -la /etc => ls.execute('-la /etc') ! # ls -la | selector | cd => ls.pipe('-la') {|lsitem| selector.pipe(lsitem) {|selitem| cd.execute(selitem)}} ! # cat foo | grep 'bar' => cat.pipe('foo') {|catitem| grep.execute('bar')} ! - def self.execute(x) - # Split the line seperated by pipes - commands = x.split("|").map{|c| c.strip} ! objects = [] ! command = nil - begin - # Save stdout - oldout = $stdout ! # Create the io string ! is = StringIO.new("") ! # Set stdout to print to it ! $stdout = is ! r = "" # bad bad bad ! commands.each do |c| ! begin - s = c.split(" ") - commandString = s[0] - rest = c[commandString.length+1..c.length] - #rest = s[1..-1].collect{ |x| File.expand_path( x ) }.join( " " ) # Breaks stuff - calias = Alias.get(commandString) - command = Commands[calias] ! if calias.strip[0] == 33 #"!" ! #$stdout = out ! cid, stdin, stdo, stderr = Open4::popen4("#{calias.strip[1..-1]} #{rest}") ! stdin.close ! pid, status = Process::waitpid2 cid ! o = stdo.read ! err = stderr.read ! r = o.strip ! r += "Errors:\n#{err}" if err != "" ! objects = [r] ! #$stdout = is ! next ! end ! if calias.strip[0] == 42 #"*" ! cid, stdin, stdout, stderr = Open4::popen4("#{calias.strip[1..-1]} #{rest}") ! stdin.close ! pid, status = Process::waitpid2 cid ! out = stdout.read ! err = stderr.read ! r = out.strip ! r += "Errors:\n#{err}" if err != "" ! objects = r.split("\n") ! next ! end ! if calias.strip[0] == 94 #"^" ! Rush.curses_stop ! system("#{calias.strip[1..-1]} #{rest}") ! r = "" ! objects = [] ! Rush.curses_start ! next ! end ! # Could not find the command, try evaluating the ruby string ! # if it evaluates, set it as the current 'objects' ! if command == nil ! begin ! objects = r = eval(c) ! r = r.to_s if !r.nil? ! objects = [objects] if objects.class != Array ! next ! rescue LoadError => detail ! return "|#{s}| "+$!.to_s+"\n" ! rescue SyntaxError => detail ! return "|#{s}| "+$!.to_s+"\n" ! rescue => detail ! return "|#{s}| "+detail.message ! end ! end - #ouch - r = "" ! command = command.new ! command.objects = objects ! if rest and not rest.empty? ! command.begin_command(rest) ! else ! command.begin_command ! end ! # evalstr = "command.begin_command" ! # evalstr += "\"#{rest.gsub("\"","\\\"")}\"" if !rest.nil? ! # eval(evalstr) ! objects = command.objects.clone ! rescue DebugException => detail ! bp("|#{c}| "+detail.message) ! return "|#{c}| "+detail.message ! rescue => detail ! return "|#{c}| "+detail.message ! end # end loop ! end # end foreach part of the pipe ! return r if !r.nil? and r != "" and (command.nil? || command.empty?) ! return command.print_collection if command != nil ! ensure ! # set it back ! $stdout = oldout ! # write out the stuff we got ! is.rewind ! is.each_line do |line| ! $bw.lines.push(line.delete("\n")) ! $bw.cury += 1 ! end ! end # end begin ensure ! end # end execute end # end class --- 1,241 ---- ! # This code perpetrated while listening to: ! # ! # Anthrax, Atomic Fireballs, Catatonia, Chicks on Speed, Common, ! # Danny Rampling, Depeche Mode, Dinosaur Jr., Duran Duran, Essence, ! # Felix da Housecat, Frankie Goes to Hollywood, Franz Ferdinand, ! # George Clinton, Idlewild, Jet, John Mayall, Johnny Cash, Kent, ! # Killers, Metallica, Ministry, Morrissey, Muse, New Order, Placebo, ! # Poe, Radiohead, Richard Ashcroft, Shivaree, Siouxsie and the Banshees, ! # Snow Patrol, Switchblade Symphony, The Bravery, The Clash, The Cult, ! # The Cure, The Sisters of Mercy, The Smiths, The Verve, Thelonious Monk, ! # Wes Montgomery, XTC and some other assorted bands. ! # ! # Just so you know. + require 'strscan' require 'stringio' ! # Binding has to be at top-level ! $pipe = nil ! $session_binding = binding ! # Namespace ! module Rush ! class Parser ! # Class instance variables ! @ruby_mode = false # Ruby parsing mode ! @ruby = '' # Store for Ruby code ! @indent = 0 # Indentation level of the Ruby code ! @session = $session_binding # Ruby code bindings for this session (used by #eval) ! # Class accessors ! meta_eval { attr_accessor :ruby_mode, :indent, :session } ! # Constants ! private ! STRING = /('([^']*?)?([^\\]'))|('')|("([^"]*?)?([^\\]"))|("")/ ! # Class methods ! public ! # ! # ! # ! def self.execute(line) ! # Capture output ! @oldout, $stdout = $stdout.dup, StringIO.new('') ! # Construct an execution sequence ! sequence = construct_from line ! # Execute ! puts "Sequence: #{sequence}" if $env[:debug] ! eval(sequence, @session).to_a.each {|line| puts line} if sequence + # Report errors depending on the type + rescue Exception => details + print_error details, sequence ! # Clean up ! ensure ! # Normalize output ! output, $stdout = $stdout, @oldout.dup + # Write to screen + output.rewind + output.each_line do |line| + $bw.lines.push(line.delete("\n")) + $bw.cury += 1 + end # output.each_line + end # self.execute(line) ! # ! # ! # ! def self.construct_from(line) ! return '' if line.empty? ! # Ruby-mode is automatic... ! return rubify(line) if @ruby_mode ! # Get the constituent parts ! sections, is_pipe = split line ! # Track locals ! name_lookup = {} ! # Generate command objects for all parts of the pipe ! cmds = sections.map {|section| ! # Get the constituent parts if needed ! command, args = section.split(/ /, 2).map {|e| e.strip} ! # Unalias and determine type of command ! # In order: system commands, special system commands (vi etc.), ! # Ruby fragments, rush commands, pure Ruby ! cmd = case Alias.get(command) ! when /^!/ then NativeFilter.new(section[1..-1]) ! when /^\^/ then CtlNativeFilter.new(section[1..-1]) ! when /^\.[^\/]/ then RubyFilter.new(section) ! else ! # Implemented commands ! if (foo = Commands[command]) != nil ! foo.new(args) ! # Ruby statements ! else ! # Standalone Ruby stuff ! if sections.size == 1 ! return rubify(line) # BREAKS OUT ! # Filter ! else ! RubyStatementFilter.new(section) ! end # if sections.size == 1 ! end # if (foo = ...) ! end # case Alias.get(command) ! # Reuse variable names for commands and ensure there ! # are no name clashes within the same pipeline. ! name = "__rush_#{cmd.class.to_s.split('::').last.downcase}_0" ! name.succ! while name_lookup[name] ! name_lookup[name] = true ! # Store the object so it will be available for calls ! bind cmd, name ! name ! } # sections.map + # Construct the pipeline ([ls, grep] => "ls.exec {grep.exec}") + seq = if cmds.size == 1 + "#{cmds.last}.exec" + else + cmds[1..-1].inject("#{cmds.first}.exec") {|memo, cmd| "#{cmd}.exec {#{memo}}"} + end # cmds.size == 1 ! # Wrap the whole thing so complete output is ensured ! "Rush.base_executor { #{seq} }" ! end # self.construct_from(line) ! # ! # ! # ! # ! def self.rubify(line) ! s = StringScanner.new line ! # Look for indentation clues ! until s.eos? ! case s.scan /.*?((#{STRING})|(def)|(class)|(module)|(begin)|(do)|(\{)|(if)|(unless)|(case)|(while)|(until)|(end)|(\}))/ ! when /#{STRING}/; next # Ignore anything in Strings ! when /end|\}/; @indent -= 1 ! when nil; break # Nothing further ! else; @indent += 1 ! end # case s.scan /.../ ! end # until s.eos? + # Output complete Ruby code only + if @indent <= 0 + # Format the Ruby output according to spec + output = if $env[:ruby_return] + "__rush_ret = (#{@ruby} #{line});" + + "'# => ' + (__rush_ret.nil? ? 'nil' : __rush_ret.to_s)" # No interpolation :/ + else + @ruby + line + '; nil' + end # if $env[:ruby_return] ! # Clean up ! @ruby_mode = false ! @ruby = '' ! @indent = 0 ! else ! # Incomplete code ! @ruby_mode = true ! @ruby += line + "\n" # Keep the user's lines ! output = nil ! end # if indent == 0 ! output ! end # self.rubify(lines) ! # ! # ! # Separate piped commands (ls | grep | wc => [ls, grep, wc]) ! def self.split(string) ! s = StringScanner.new(string) ! sections = [] ! base = 0 ! real_pipe = false ! # Ruby code has some pipe characters, too ! until s.eos? ! case s.scan /.*?((((\{|do)\s*\|[^|]*\|))|(#{STRING})|(\|\|)|(\\\|)|([|]))/ ! # Remove false positives ! # (Do not change this order.) ! when /(((\{|do)\s*\|[^|]*\|))/ # Block ! when /#{STRING}/ # Strings ! when /\|\|/ # OR ! when /\\\|/ # Escaped pipe ! next ! # Pipes ! when /[|]/ ! real_pipe = true ! sections << string[base...s.pos].chop.strip # Remove the | ! base = s.pos ! # No further matches, store the remainder ! when nil ! break ! end # case s.match ! end # until s.eos ! # Adjust the results ! sections << string[base..-1].strip ! sections.map! {|sec| sec.gsub /\\\|/, '|'} ! [sections, real_pipe] ! end # self.split(string) ! # Bind a given object to the session-local variable name. ! def self.bind(object, name) ! eval("#{name} = ObjectSpace._id2ref(#{object.object_id})", @session) ! end ! def self.print_error(details, sequence) ! syntax_error = '^__rush_ret = \((.*?)\);\'# => \' \+ \(__rush_ret' + case details + when SyntaxError + puts "| Syntax error | #{details.message}" #<< + "#{"\n In:\n#{sequence.scan(/#{syntax_error}/).first.first}" if $env[:debug]}" ! when Exception ! puts "| Error | #{details.message}" << ! "#{"\n#{details.backtrace.join("\n")}" if $env[:debug]}" ! end # case details ! end # self.print_error(details, sequence) end # end class Index: general.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/general.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** general.rb 30 Aug 2005 06:26:37 -0000 1.3 --- general.rb 18 Sep 2005 23:53:55 -0000 1.4 *************** *** 51,55 **** Curses.stdscr.keypad true ! rush_init_curses end --- 51,55 ---- Curses.stdscr.keypad true ! #rush_init_curses end Index: default_config.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/default_config.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** default_config.rb 31 Aug 2005 18:31:56 -0000 1.7 --- default_config.rb 18 Sep 2005 23:53:55 -0000 1.8 *************** *** 29,64 **** # Authors are not responsible for any damages, direct or indirect. - module Rush - ################################################################## - # default init functions - # You can copy this file to ~/.rushrc for a per user setting - ################################################################## ! require 'yaml' # Sets up colors ! def self.rush_init_curses ! Curses.init_pair(1,Curses::COLOR_WHITE,Curses::COLOR_BLUE) # Main screen colors ! Curses.init_pair(2,Curses::COLOR_BLACK,Curses::COLOR_WHITE)# Selected item colors ! Curses.init_pair(3,Curses::COLOR_WHITE,Curses::COLOR_RED) # Box colors ! end ! # Right before curses is started ! # everything here should be non destructive if run a second time ! def self.rush_startup ! $env = {} ! #$env[:prompt] = "Dir.getwd.to_s+\"> \"" ! $env[:prompt] = %Q{Rush::FsManager.current_fs.respond_to+":/"+Rush::FsManager.current_path+"> "} ! $env[:selection_attr] = Curses::A_STANDOUT ! $env[:stackdsize] = 10 ! Alias.set("vi","^vi") ! Alias.set("cat","!cat") ! end - # Right after curses is shutdown - def self.rush_shutdown - end ! end # Module --- 29,61 ---- # Authors are not responsible for any damages, direct or indirect. ! # Namespace ! module Rush # Sets up colors ! Curses.init_pair(1,Curses::COLOR_WHITE,Curses::COLOR_BLUE) # Main screen colors ! Curses.init_pair(2,Curses::COLOR_BLACK,Curses::COLOR_WHITE) # Selected item colors ! Curses.init_pair(3,Curses::COLOR_WHITE,Curses::COLOR_RED) # Box colors ! # Environment defaults ! $env = {} ! $env[:prompt] = %Q|Rush::FsManager.current_fs.respond_to+":/"+Rush::FsManager.current_path+"> "| ! $env[:rubyprompt] = %Q|" ruby-mode " + Rush::Parser.indent.to_s + "> "| ! $env[:selection_attr] = Curses::A_STANDOUT ! $env[:stackdsize] = 10 ! # Debug-type stuff ! $env[:debug] = false # General debugging ! $env[:ruby_return] = false # Does Ruby show its return values? ! Alias.set("vi","^vi") ! Alias.set("cat","!cat") ! ! # Dummy methods (override in ~/.rushrc) ! def self.on_startup(); end ! def self.on_shutdown(); end ! ! ! end # module Rush Index: alias.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/alias.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** alias.rb 30 Aug 2005 06:26:37 -0000 1.2 --- alias.rb 18 Sep 2005 23:53:55 -0000 1.3 *************** *** 44,50 **** def self.get(key) ! ret = @@aliases[key] ! ret = key if ret.nil? ! return ret end --- 44,48 ---- def self.get(key) ! @@aliases[key] or key end From rue at rubyforge.org Sun Sep 18 19:53:57 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Sun, 18 Sep 2005 23:53:57 +0000 Subject: [Rush-developer] rush/lib/rush/keys ruby_mode.rb enter.rb key.rb Message-ID: <200509182353.j8INrv05019843@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush/keys In directory rubyforge.org:/tmp/cvs-serv19749/lib/rush/keys Modified Files: enter.rb key.rb Added Files: ruby_mode.rb Log Message: Huge update. - default_config.rb just executes its contents rather than defining methods to be called to do it. - default_config does define dummies on_startup and on_shutdown. These should be overridden in ~/.rushrc - bin/rush just #requires default_config - Default ruby-mode prompt in default_config.rb. - Key#execute raises NotImplementedError instead of Exception. - Removed handling of Parser.execute from keys/enter.rb - keys/ruby_mode.rb to implement ^R ruby-mode control. - Completely rewrote parser.rb to support the new piping and ruby-mode. - Executing & 'remembering' *arbitrary Ruby* from the line supported. - commands/special_commands.rb to implement special processing for types of piped sections. - command.rb rewritten to facilitate the piping. - $env[:rubyreturn] decides how Ruby statements are output. If it is true, each statement is followed by # => , somewhat like irb. By default not set in which case the return value is swallowed. - Rudimentary support for pushing input to system commands: 'foo' | !grep 'foo' - $env[:debug] to control general debug info output. - All Commands adhere to the new syntax. - commands/print.rb and toglobal.rb are being deprecated as useless. Index: enter.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/keys/enter.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** enter.rb 30 Aug 2005 06:26:37 -0000 1.2 --- enter.rb 18 Sep 2005 23:53:55 -0000 1.3 *************** *** 36,39 **** --- 36,42 ---- def execute(ch,promptString) + # THIS STUFF HAS TO MOVE SOMEWHERE ELSE! + # (Preferably parser.rb.) + ret = "" begin *************** *** 45,57 **** end ret = Parser.execute(line) ! rescue => detail ! ret = $!.to_s+"\n" #+detail.backtrace.join("\n") ! rescue SyntaxError => detail ! ret = $!.to_s+"\n" #+detail.backtrace.join("\n") end # Reset the prompt screen here, it might have been changed promptString = eval($env[:prompt]) - ret.split("\n").map{|l| $bw.add_line(l); $bw.cury += 1} if ret != nil $bw.cury += 1; $bw.lines.push(promptString) $bw.curx = promptString.length --- 48,62 ---- end ret = Parser.execute(line) ! # rescue => detail ! # ret = $!.to_s+"\n" #+detail.backtrace.join("\n") ! # rescue SyntaxError => detail ! # ret = $!.to_s+"\n" #+detail.backtrace.join("\n") end + # THIS TOO + # (Probably bin/rush.) + # Reset the prompt screen here, it might have been changed promptString = eval($env[:prompt]) $bw.cury += 1; $bw.lines.push(promptString) $bw.curx = promptString.length --- NEW FILE: ruby_mode.rb --- # == Authors # Please see doc/AUTHORS. # # == Copyright # Copyright (c) 2005 the Authors, all rights reserved. # # == Licence # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # - Redistributions of source code must retain the above copyright # notice, this list of conditions, the following disclaimer and # attribution to the original authors. # # - Redistributions in binary form must reproduce the above copyright # notice, this list of conditions, the following disclaimer and # attribution to the original authors in the documentation and/or # other materials provided with the distribution. # # - The names of the authors may not be used to endorse or promote # products derived from this software without specific prior # written permission. # # == Disclaimer # This software is provided "as is" and without any express or # implied warranties, including, without limitation, the implied # warranties of merchantability and fitness for a particular purpose. # Authors are not responsible for any damages, direct or indirect. # Namespace module Rush class RubyMode < Key respond_to [18] # ^R def execute(ch, prompt) # TODO: Implement some sort of exiting? Parser.ruby_mode = true end # execute(ch, prompt) end # class RubyMode end # module Rush Index: key.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/keys/key.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** key.rb 30 Aug 2005 06:26:37 -0000 1.4 --- key.rb 18 Sep 2005 23:53:55 -0000 1.5 *************** *** 56,60 **** def execute(char, prompt_string) # Ensure adherence to protocol ! raise Exception.new("#execute not implemented for key binding!") end # self.execute(char, prompt_string) end # class Key --- 56,60 ---- def execute(char, prompt_string) # Ensure adherence to protocol ! raise NotImplementedError.new("#execute not implemented for key binding!") end # self.execute(char, prompt_string) end # class Key From rue at rubyforge.org Sun Sep 18 19:53:57 2005 From: rue at rubyforge.org (rue@rubyforge.org) Date: Sun, 18 Sep 2005 23:53:57 +0000 Subject: [Rush-developer] rush/lib/rush/commands special_commands.rb bracket.rb command.rb commands.rb dirname.rb dirs.rb keycode.rb ls.rb out.rb popd.rb print.rb pushd.rb pwd.rb selector.rb to_global.rb Message-ID: <200509182353.j8INrv05019828@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush/commands In directory rubyforge.org:/tmp/cvs-serv19749/lib/rush/commands Modified Files: bracket.rb command.rb commands.rb dirname.rb dirs.rb keycode.rb ls.rb out.rb popd.rb print.rb pushd.rb pwd.rb selector.rb to_global.rb Added Files: special_commands.rb Log Message: Huge update. - default_config.rb just executes its contents rather than defining methods to be called to do it. - default_config does define dummies on_startup and on_shutdown. These should be overridden in ~/.rushrc - bin/rush just #requires default_config - Default ruby-mode prompt in default_config.rb. - Key#execute raises NotImplementedError instead of Exception. - Removed handling of Parser.execute from keys/enter.rb - keys/ruby_mode.rb to implement ^R ruby-mode control. - Completely rewrote parser.rb to support the new piping and ruby-mode. - Executing & 'remembering' *arbitrary Ruby* from the line supported. - commands/special_commands.rb to implement special processing for types of piped sections. - command.rb rewritten to facilitate the piping. - $env[:rubyreturn] decides how Ruby statements are output. If it is true, each statement is followed by # => , somewhat like irb. By default not set in which case the return value is swallowed. - Rudimentary support for pushing input to system commands: 'foo' | !grep 'foo' - $env[:debug] to control general debug info output. - All Commands adhere to the new syntax. - commands/print.rb and toglobal.rb are being deprecated as useless. Index: selector.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/selector.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** selector.rb 31 Aug 2005 01:18:50 -0000 1.3 --- selector.rb 18 Sep 2005 23:53:55 -0000 1.4 *************** *** 31,56 **** module Rush ! class Selector < Command respond_to "selector" ! def begin_command(args='') ! super ! ! raise NoInformationException.new(true,"No information passed") if @objects == nil || @objects.empty? ! list = @objects.map{|o| Item.new(o.to_s)} ! b = ComboBox.new(Curses::stdscr,$bw.cury,$bw.curx,10,list) b.run raise PipelineStopedException.new("Selector canceled") if !b.accepted ! @objects = [b.items[b.item].text] # need this $bw.clear $bw.display end end --- 31,75 ---- module Rush ! # class Selector < Command ! class Selector < BlockFilter respond_to "selector" ! def execute() ! return [nil, :done] if @input.empty? ! list = @input.map{|obj| Item.new(obj.to_s)} ! b = ComboBox.new(Curses::stdscr, $bw.cury, $bw.curx, 10, list) b.run raise PipelineStopedException.new("Selector canceled") if !b.accepted ! selection = [b.items[b.item].text] # need this $bw.clear $bw.display + + [selection, :done] end + # def begin_command(args='') + # super + # + # raise NoInformationException.new(true,"No information passed") if @objects == nil || @objects.empty? + # + # list = @objects.map{|o| Item.new(o.to_s)} + # b = ComboBox.new(Curses::stdscr,$bw.cury,$bw.curx,10,list) + # b.run + # + # raise PipelineStopedException.new("Selector canceled") if !b.accepted + # + # @objects = [b.items[b.item].text] + # + # # need this + # $bw.clear + # $bw.display + # end + end Index: print.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/print.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** print.rb 31 Aug 2005 01:18:50 -0000 1.3 --- print.rb 18 Sep 2005 23:53:55 -0000 1.4 *************** *** 29,48 **** # Authors are not responsible for any damages, direct or indirect. - module Rush - - - class Print < Command - - respond_to "print" - - def begin_command(args='') - super - @objects = [eval(args.to_s).to_s] - end ! def end_command(*args) ! end ! ! end ! end #module --- 29,55 ---- # Authors are not responsible for any damages, direct or indirect. ! # ! # No need for this ! # ! # module Rush ! # ! # ! # # class Print < Command ! # class Print < BlockFilter ! # ! # respond_to "print" ! # ! # # ??? ! # def execute() ! # [eval(@args.to_s).to_s, :done] ! # end ! # # def begin_command(args='') ! # # super ! # # @objects = [eval(args.to_s).to_s] ! # # end ! # ! # end ! # ! # end #module Index: popd.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/popd.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** popd.rb 31 Aug 2005 01:18:50 -0000 1.2 --- popd.rb 18 Sep 2005 23:53:55 -0000 1.3 *************** *** 31,52 **** module Rush ! class Popd < Command ! respond_to "popd" ! def begin_command(args = '') ! super ! $env[:stackd] ||= [] ! if $env[:stackd][-1] == Dir.pwd ! $env[:stackd].pop ! end ! if !$env[:stackd].nil? and !$env[:stackd].empty? ! Dir.chdir($env[:stackd][-1]) ! else ! puts "popd: directory stack empty." ! end ! end end --- 31,68 ---- module Rush ! # class Popd < Command ! class Popd < BlockFilter ! respond_to "popd" ! def execute() ! $env[:stackd] ||= [] ! if $env[:stackd][-1] == Dir.pwd ! $env[:stackd].pop ! end ! if !$env[:stackd].nil? and !$env[:stackd].empty? ! Dir.chdir($env[:stackd][-1]) ! # Change this return? ! [Dir.pwd, :done] ! else ! ['popd: Directory stack empty.', :done] ! end ! end ! # def begin_command(args = '') ! # super ! # $env[:stackd] ||= [] ! # ! # if $env[:stackd][-1] == Dir.pwd ! # $env[:stackd].pop ! # end ! # ! # if !$env[:stackd].nil? and !$env[:stackd].empty? ! # Dir.chdir($env[:stackd][-1]) ! # else ! # puts "popd: directory stack empty." ! # end ! # end end Index: bracket.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/bracket.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** bracket.rb 31 Aug 2005 01:18:50 -0000 1.3 --- bracket.rb 18 Sep 2005 23:53:55 -0000 1.4 *************** *** 32,44 **** ! class Bracket < Command respond_to "b" ! def begin_command(args='') ! super ! @objects.map!{|o| "("+o.to_s+")"} ! end end --- 32,48 ---- ! #class Bracket < Command ! class Bracket < BlockFilter respond_to "b" ! def execute() ! [@input.map {|obj| "(#{obj})"}, :done] ! end # execute() + # def begin_command(args='') + # super + # @objects.map!{|o| "("+o.to_s+")"} + # end end Index: pwd.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/pwd.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pwd.rb 31 Aug 2005 01:18:50 -0000 1.2 --- pwd.rb 18 Sep 2005 23:53:55 -0000 1.3 *************** *** 31,42 **** module Rush ! class Pwd < Command ! respond_to "pwd" ! def begin_command(args = '') ! super ! @objects = [Dir.pwd] ! end end --- 31,46 ---- module Rush ! # class Pwd < Command ! class Pwd < BlockFilter ! respond_to "pwd" ! def execute() ! [Dir.pwd, :done] ! end ! # def begin_command(args = '') ! # super ! # @objects = [Dir.pwd] ! # end end Index: command.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/command.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** command.rb 2 Sep 2005 04:56:24 -0000 1.9 --- command.rb 18 Sep 2005 23:53:55 -0000 1.10 *************** *** 34,39 **** --- 34,128 ---- require 'yaml' + + class Command + def initialize(line) + @done = false + @output = nil + @input = [] + @line = line + @args = parse_options(line) + end + + # Each new section of input is stored by expanding it in + # @input; this way we ensure that consecutive inputs are + # treated as one ([1,2], [3,[4,5]] => [1,2,3,[4,5]] and + # 'foo' => ['foo'] and [[1,2]], [[3.4]] => [[1,2],[3,4]]) + # as most likely will be the desirable behaviour. However, + # this may be bad if the preceding filter intentionally + # produces separate Arrays which should be kept intact. + # To avoid problems, such Arrays should be returned as + # [] from #execute. They will be rewrapped in #exec so + # the storage method ends up with the original. + # + # If the command can operate on partials, its + # result will also be partial. We expect that + # this object's #exec will be called again so + # that this operation can be completed. + # + # In the event that partial output is produced, + # a flag must be set inside #execute. It is not + # necessary to signal complete output as the flag + # is defaulted to :done. + # + # Be aware that @input and @output will be erased + # whenever exiting this method. + def exec() + # May have to process multiple times + loop do + # Obtain input if such is available + input, status = yield if block_given? + + # Store without creating extra Arrays. + @input.push(*input) unless input == [nil] + + # Incomplete input? + if status == :partial + next unless @partials_ok + output, completion = execute + # Incomplete input must, by definition, produce incomplete output + return [[*output], :partial] + + # Complete + else + output, completion = execute + return [[*output], completion || :done] + end # if status == :partial + end # loop + + # Clean up + ensure + @input = [], @output = nil + end # exec() + + + # It is expected that #execute returns an Array [data, status]. + # The status is optional and defaults to :done (use :partial if + # there will be more output later). However, if you omit the + # status, you _must_ enclose the return value in an Array, i.e. + # either 'return [x, :done]' or 'return [x]'. It is strongly + # recommended that you always set the status flag yourself + # because omitting the brackets will cause serious problems. + # + # TODO: Maybe create a proxy between exec and execute to check + # the correctness of the return? + # + # GET RID OF THIS? + # Be aware that #exec will ensure that everything it outputs + # is an Array. This means that if you are returning an Array, + # it will be unchanged but any individual object becomes [obj]. + # This is done to simplify the handling of partial input. By + # default partial input is treated simply as segments of the + # whole which is to say that each Array that it receives, #exec + # appends to the previous input ([1,2], [3,[4,5]] => [1,2,3,[4,5]]). + # + # If you are producing partial input and would like each chunk + # to be treated as an individual Array, wrap them into Arrays + # yourself ([[1,2]]). This way the Array is preserved in #exec. + def execute() + raise NotImplementedError.new("No #{self.class}#execute!") + end + class << self; attr_reader :options; end attr_accessor :objects *************** *** 42,47 **** def self.respond_to(names) names.to_a.each {|name| Commands.add(name, self)} - #class << self; define_method(:responds_to) {names}; end - #meta_def :responds_to do; names; end end --- 131,134 ---- *************** *** 85,147 **** } # lookup.each # Return all non-option args result[:args] } # define_method(:parse_options) end # self.options(opts) ! ! def writeObject(obj) ! @objects += obj end ! def print_collection ! # If there are objects left after all the commands, print them ! return if @objects.empty? ! ! ret = "" ! ! currentType = nil ! properties = nil ! @objects.each do |o| ! ! # Check if the header should be written again ! if currentType != o.class ! currentType = o.class ! ! if o.respond_to?("properties") ! properties = o.properties ! # Write the headers ! o.properties.each {|p| ret += p[0] + "\t"} ! ret += "\n" ! o.properties.each do |p| ! ret += "-"*p[0].length ! ret += "\t" ! end ! ret += "\n" ! end ! ! end ! ! # Write the object ! if o.respond_to?("properties") ! o.properties.each{|p| ret += p[1] + "\t"} ! else ! ret+=o.to_s ! end ! ! ret += "\n" ! end ! return ret ! end ! def begin_command(args=nil) ! end ! def end_command(args) end ! def initialize(objects = []) ! @objects = objects end - end --- 172,249 ---- } # lookup.each # Return all non-option args + # FIX: may be incompatible with dummy result[:args] } # define_method(:parse_options) end # self.options(opts) ! # DEFAULT ! def parse_options(args) ! args end ! # def writeObject(obj) ! # @objects += obj ! # end ! # ! # def print_collection ! # # If there are objects left after all the commands, print them ! # return if @objects.empty? ! # ! # ret = "" ! # ! # currentType = nil ! # properties = nil ! # @objects.each do |o| ! # ! # # Check if the header should be written again ! # if currentType != o.class ! # currentType = o.class ! # ! # if o.respond_to?("properties") ! # properties = o.properties ! # # Write the headers ! # o.properties.each {|p| ret += p[0] + "\t"} ! # ret += "\n" ! # o.properties.each do |p| ! # ret += "-"*p[0].length ! # ret += "\t" ! # end ! # ret += "\n" ! # end ! # ! # end ! # ! # # Write the object ! # if o.respond_to?("properties") ! # o.properties.each{|p| ret += p[1] + "\t"} ! # else ! # ret+=o.to_s ! # end ! # ! # ret += "\n" ! # end ! # return ret ! # end ! # ! # def begin_command(args=nil) ! # end ! # ! # def end_command(args) ! # end ! end ! class BlockFilter < Command ! def initialize(line) ! super ! @partials_ok = false end + end ! class LineFilter < Command ! def initialize(line) ! super ! @partials_ok = true end end Index: commands.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/commands.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** commands.rb 1 Sep 2005 07:07:42 -0000 1.6 --- commands.rb 18 Sep 2005 23:53:55 -0000 1.7 *************** *** 37,41 **** class Commands - #@@commands = [] @commands = {} --- 37,40 ---- *************** *** 48,54 **** end ! def self.[](name) ! @commands[name] ! end def self.find_respond_to(name) --- 47,55 ---- end ! # Locate a Command of some kind ! def self.[](cmd) ! @commands[cmd] ! end # self.[](line) ! def self.find_respond_to(name) Index: out.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/out.rb,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** out.rb 31 Aug 2005 01:18:50 -0000 1.3 --- out.rb 18 Sep 2005 23:53:55 -0000 1.4 *************** *** 32,48 **** ! class Out < Command respond_to "out" ! def begin_command(args='') ! super ! args = "out" if args.nil? ! file = File.open(args,"w") ! @objects.each{|o| file << o.to_s << "\n"} ! file.close end end --- 32,63 ---- ! #class Out < Command ! class Out < BlockFilter respond_to "out" ! def execute() ! file = if @args and not @args.empty? ! @args ! else ! 'out' ! end ! File.open(file, 'w+b') do |f| ! @input.each {|obj| f.puts obj.to_s} ! end ! # Maybe return nil? ! [nil, :done] end + # def begin_command(args='') + # super + # + # args = "out" if args.nil? + # + # file = File.open(args,"w") + # @objects.each{|o| file << o.to_s << "\n"} + # file.close + # end end Index: pushd.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/pushd.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pushd.rb 31 Aug 2005 18:31:56 -0000 1.6 --- pushd.rb 18 Sep 2005 23:53:55 -0000 1.7 *************** *** 31,85 **** module Rush ! class Pushd < Command ! ! respond_to ["pushd","cd"] ! ! def begin_command(args = ENV[ "HOME" ] ) ! super ! FsManager.navigate(args) ! end ! ! def begin_command3( args = ENV[ "HOME" ] ) ! super ! $env[ :stackd ] ||= [] ! ! # args = File.expand_path( args ) ! if File.directory?( args ) and Dir.pwd != args ! begin ! Dir.chdir( args ) ! $env[:stackd].push( Dir.pwd ) unless $env[:stackd][-1] == Dir.pwd ! rescue SystemCallError ! puts "Could not change directories. System error `#{$!}'" ! end ! elsif File.exist?( args ) ! puts 'pushd: not a directory: ' + args ! else ! puts 'pushd: no such file or directory: '+args ! end ! ! $env[:stackd] = $env[:stackd].reverse[0 .. $env[:stackdsize].to_i ].reverse ! ! $env[:stackd].each{ |x| puts "Dir: #{x}" } ! end ! ! def begin_command2(args=ENV["HOME"]) ! super ! $env[:stackd] ||= [] ! #add the current dir unless its the one we're in ! $env[:stackd].push(Dir.pwd) unless $env[:stackd][-1] == Dir.pwd ! if File.directory?(args) ! Dir.chdir(args) ! #add the new dir unless its the one we're in ! $env[:stackd].push(Dir.pwd) unless $env[:stackd][-1] == Dir.pwd ! elsif File.exist?(args) ! puts 'pushd: not a directory: '+args ! else ! puts 'pushd: no such file or directory: '+args ! end ! #trim the stack ! $env[:stackd] = $env[:stackd].reverse[0, $env[:stackdsize].to_i].reverse end end --- 31,90 ---- module Rush ! #class Pushd < Command ! class Pushd < BlockFilter ! respond_to ["pushd", "cd"] ! def execute() ! FsManager.navigate @args ! [nil, :done] end + # def begin_command(args = ENV[ "HOME" ] ) + # super + # FsManager.navigate(args) + # end + # + # def begin_command3( args = ENV[ "HOME" ] ) + # super + # $env[ :stackd ] ||= [] + # + # # args = File.expand_path( args ) + # if File.directory?( args ) and Dir.pwd != args + # begin + # Dir.chdir( args ) + # $env[:stackd].push( Dir.pwd ) unless $env[:stackd][-1] == Dir.pwd + # rescue SystemCallError + # puts "Could not change directories. System error `#{$!}'" + # end + # elsif File.exist?( args ) + # puts 'pushd: not a directory: ' + args + # else + # puts 'pushd: no such file or directory: '+args + # end + # + # $env[:stackd] = $env[:stackd].reverse[0 .. $env[:stackdsize].to_i ].reverse + # + # $env[:stackd].each{ |x| puts "Dir: #{x}" } + # end + # + # def begin_command2(args=ENV["HOME"]) + # super + # $env[:stackd] ||= [] + # + # #add the current dir unless its the one we're in + # $env[:stackd].push(Dir.pwd) unless $env[:stackd][-1] == Dir.pwd + # + # if File.directory?(args) + # Dir.chdir(args) + # #add the new dir unless its the one we're in + # $env[:stackd].push(Dir.pwd) unless $env[:stackd][-1] == Dir.pwd + # elsif File.exist?(args) + # puts 'pushd: not a directory: '+args + # else + # puts 'pushd: no such file or directory: '+args + # end + # #trim the stack + # $env[:stackd] = $env[:stackd].reverse[0, $env[:stackdsize].to_i].reverse + # end end --- NEW FILE: special_commands.rb --- module Rush def self.base_executor() # Need something to execute return unless block_given? # Store output in case of partials out = [] # Complete output loop { # Get data output, status = yield # Append any data out.push(*output) unless output == [nil] break if status == :done } # Accumulation out end class RubyFilter < BlockFilter # The line is probably something like '.each {|e| puts e}' def execute() #return "In RubyFilter(#{@line}): [#{@input}]" # Decide how to invoke the given fragment. # A single element is likely desirable to be evaluated # by itself whereas multiple elements indicate that the # user was (hopefully) expecting an Array. # A single element should be evaluated by itself if @input.size == 1 Parser.bind @input.first, "__rush_rf_input" # An Array else Parser.bind @input, "__rush_rf_input" end # Execute [eval("__rush_rf_input#{@line}", Parser.session), :done] end end class RubyStatementFilter < BlockFilter # Complete Ruby statements with the additional benefit # of $pipe representing the last forwarded value from # the current pipe sequence. def execute() # Similarly to RubyFilter, a single input element # will be extracted to be operated on on its own # whereas multiple thereof are returned as an Array. # Make the previous result available. $pipe = if @input.size == 1 @input.first else @input end # if input.size == 1 # Execute the code fragment given [eval(@line, Parser.session), :done] end end class NativeFilter < BlockFilter def execute() # # Trivially implemented for right now. # Probably need to loop this so that # partial input may be accepted and # also given as output for long-running # programs. # # Open a pipe for the outside process cid, stdin, stdout, stderr = Open4.popen4(@line) # Attempt to push input if such is available if @input and not @input == [nil] begin; stdin.write(@input.flatten.join("\n")); rescue Errno::EPIPE; end end # Unable to read if input is not terminated stdin.close # Wait for the child to exit pid, status = Process::waitpid2 cid # Read in the results @output, @errors = stdout.read, stderr.read # Display any problems @output << "\nErrors:\n" << @errors unless @errors.empty? # Array of Strings is better for processing [@output.split] end end class CtlNativeFilter < NativeFilter def execute() # # Trivially implemented for right now. # # Jump out of Curses mode Rush.curses_stop Kernel.system(@line) Rush.curses_start # Nothing to return [] end end end Index: ls.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/ls.rb,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ls.rb 2 Sep 2005 08:00:45 -0000 1.11 --- ls.rb 18 Sep 2005 23:53:55 -0000 1.12 *************** *** 2,30 **** ! class Ls < Command respond_to "ls" - option :name => 'help', :key => 'h', :method => :help, :desc => "Displays a help." - - def help(*args) - puts "Shows the contents of a directory. Usage: ls [path]" - end - - def begin_command(args = '.') - super - @objects = Dir.entries(File.expand_path(args)) - # args = parse_options(args) - # dir = args.last || '.' - # @objects = Dir.entries(File.expand_path(dir)) - # Not sure what is up with this - #(FsManager.list_children+FsManager.list_items).sort - end ! def end_command(*args) ! end ! ! def initialize ! super end end --- 2,36 ---- ! #class Ls < Command ! class Ls < BlockFilter respond_to "ls" ! def execute() ! # FIX: Enable globbing ! [Dir.entries(File.expand_path(@args || '.')), :done] end + # option :name => 'help', :key => 'h', :method => :help, :desc => "Displays a help." + # + # def help(*args) + # puts "Shows the contents of a directory. Usage: ls [path]" + # end + # + # def begin_command() + # super + # @objects = Dir.entries(File.expand_path(args)) + # # args = parse_options(args) + # # dir = args.last || '.' + # # @objects = Dir.entries(File.expand_path(dir)) + # # Not sure what is up with this + # #(FsManager.list_children+FsManager.list_items).sort + # end + # + # def end_command(*args) + # end + # + # def initialize + # super + # end end Index: dirs.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/dirs.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dirs.rb 31 Aug 2005 18:31:56 -0000 1.4 --- dirs.rb 18 Sep 2005 23:53:55 -0000 1.5 *************** *** 31,52 **** module Rush ! class Dirs < Command respond_to "dirs" ! def begin_command(args = "") ! super ! $env[:stackd] ||= [] ! if $env[:stackd].empty? ! #empty stack, send current folder ! stack = [Dir.pwd] ! else ! #reverse them because that's how the real dirs does it ! stack = $env[:stackd].reverse ! end ! @objects = stack ! end end --- 31,67 ---- module Rush ! # class Dirs < Command ! class Dirs < BlockFilter respond_to "dirs" ! def execute() ! $env[:stackd] ||= [] ! # Empty stack ! stack = if $env[:stackd].empty? ! [Dir.pwd] ! # Reverse, following the standard dirs ! else ! $env[:stackd].reverse ! end # if $env[:stackd].empty? ! [stack, :done] ! end ! ! # def begin_command(args = "") ! # super ! # ! # $env[:stackd] ||= [] ! # ! # if $env[:stackd].empty? ! # #empty stack, send current folder ! # stack = [Dir.pwd] ! # else ! # #reverse them because that's how the real dirs does it ! # stack = $env[:stackd].reverse ! # end ! # @objects = stack ! # end end Index: dirname.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/dirname.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dirname.rb 31 Aug 2005 01:18:50 -0000 1.2 --- dirname.rb 18 Sep 2005 23:53:55 -0000 1.3 *************** *** 31,66 **** module Rush ! class Dirname < Command respond_to 'dirname' ! def begin_command(args='') ! super ! ! #error out when no args ! unless args ! puts 'dirname: too few arguments' ! return ! end ! ! #strip trailing slash ! args.chomp!('/') ! ! #loop through the last characters, removing if not a / ! while args[-1] and args[-1].chr != '/' ! args = args[0..-2] ! end ! #if the arg length is still > 1, trim a trailing / ! while args.length > 1 and args[-1].chr == '/' ! args.chomp!('/') ! end - #otherwise we have an empty path - if args.length == 0 - args = '.' - end - puts args end end --- 31,74 ---- module Rush ! # class Dirname < Command ! class Dirname < BlockFilter respond_to 'dirname' ! def execute() ! return ['dirname: Too few arguments.', :done] if @args.empty? ! # FIX: Returns '' when /foo or ../ or something ! [@args.first.split(%r|(?!^)/|)[0...-1].join('/'), :done] end + # def begin_command(args='') + # super + # + # #error out when no args + # unless args + # puts 'dirname: too few arguments' + # return + # end + # + # #strip trailing slash + # args.chomp!('/') + # + # #loop through the last characters, removing if not a / + # while args[-1] and args[-1].chr != '/' + # args = args[0..-2] + # end + # + # #if the arg length is still > 1, trim a trailing / + # while args.length > 1 and args[-1].chr == '/' + # args.chomp!('/') + # end + # + # #otherwise we have an empty path + # if args.length == 0 + # args = '.' + # end + # puts args + # end end Index: keycode.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/keycode.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** keycode.rb 31 Aug 2005 01:18:50 -0000 1.4 --- keycode.rb 18 Sep 2005 23:53:55 -0000 1.5 *************** *** 36,50 **** respond_to "keycode" ! def begin_command(args='') ! super ! $bw.lines.push("Enter a key:"); $bw.curx = 13; $bw.cury += 1 $bw.show_bottom $bw.display ! ch = $bw.getch() ! @objects = [ch] ! end end --- 36,57 ---- respond_to "keycode" ! def execute() $bw.lines.push("Enter a key:"); $bw.curx = 13; $bw.cury += 1 $bw.show_bottom $bw.display ! [$bw.getch(), :done] end + # def begin_command(args='') + # super + # + # $bw.lines.push("Enter a key:"); $bw.curx = 13; $bw.cury += 1 + # $bw.show_bottom + # $bw.display + # + # ch = $bw.getch() + # @objects = [ch] + # + # end end Index: to_global.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/commands/to_global.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** to_global.rb 30 Aug 2005 06:26:37 -0000 1.2 --- to_global.rb 18 Sep 2005 23:53:55 -0000 1.3 *************** *** 29,46 **** # Authors are not responsible for any damages, direct or indirect. - module Rush - ! class ToGlobal < Command ! ! respond_to "toglobal" ! ! def begin_command(args="glob") ! super ! eval("$#{args} = @objects.clone") ! @objects = [] ! end ! ! end ! end --- 29,51 ---- # Authors are not responsible for any damages, direct or indirect. ! # ! # No need for this at all anymore ! # ! # module Rush ! # ! # ! # class ToGlobal < Command ! # ! # respond_to "toglobal" ! # ! # def begin_command(args="glob") ! # super ! # eval("$#{args} = @objects.clone") ! # @objects = [] ! # end ! # ! # end ! # ! # end From kbrooks at rubyforge.org Sun Sep 18 20:04:26 2005 From: kbrooks at rubyforge.org (kbrooks@rubyforge.org) Date: Mon, 19 Sep 2005 00:04:26 +0000 Subject: [Rush-developer] rush/doc AUTHORS Message-ID: <200509190004.j8J04Q05023718@rubyforge.org> Update of /var/cvs/rush/rush/doc In directory rubyforge.org:/tmp/cvs-serv23712/doc Modified Files: AUTHORS Log Message: Added save/load to Rush::History Index: AUTHORS =================================================================== RCS file: /var/cvs/rush/rush/doc/AUTHORS,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AUTHORS 31 Aug 2005 18:31:56 -0000 1.3 --- AUTHORS 19 Sep 2005 00:04:24 -0000 1.4 *************** *** 2,6 **** - Reyn Vliestsra ! - Kyle Brooks - Jon Rafkind - Eero Saynatkari --- 2,6 ---- - Reyn Vliestsra ! - Kyle Brooks - Jon Rafkind - Eero Saynatkari From kbrooks at rubyforge.org Sun Sep 18 20:04:26 2005 From: kbrooks at rubyforge.org (kbrooks@rubyforge.org) Date: Mon, 19 Sep 2005 00:04:26 +0000 Subject: [Rush-developer] rush/lib/rush history.rb Message-ID: <200509190004.j8J04Q05023720@rubyforge.org> Update of /var/cvs/rush/rush/lib/rush In directory rubyforge.org:/tmp/cvs-serv23712/lib/rush Modified Files: history.rb Log Message: Added save/load to Rush::History Index: history.rb =================================================================== RCS file: /var/cvs/rush/rush/lib/rush/history.rb,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** history.rb 30 Aug 2005 06:26:37 -0000 1.2 --- history.rb 19 Sep 2005 00:04:24 -0000 1.3 *************** *** 43,51 **** return @@lines[ arg ] end def self.[]= ( arg, value ) @@lines[ arg ] = value end - def self.current_line return @@current_line --- 43,51 ---- return @@lines[ arg ] end + def self.[]= ( arg, value ) @@lines[ arg ] = value end def self.current_line return @@current_line *************** *** 56,59 **** end ! end end # module --- 56,74 ---- end ! def self.save file=nil ! unless file ! file = "#{ENV['HOME']}/.rush_history" ! end ! File.open(file) {|fp| ! fp.writelines @@lines ! } ! end ! ! def self.load file=nil ! unless file ! file = "#{ENV['HOME']}/.rush_history" ! end ! @@lines = IO.readlines file ! end ! end # class end # module From rush-devel-ml at magical-cat.org Wed Sep 21 04:39:31 2005 From: rush-devel-ml at magical-cat.org (ES) Date: Wed, 21 Sep 2005 08:39:31 +0000 Subject: [Rush-developer] darcs Message-ID: <43311C43.6000604@magical-cat.org> Hey. I got tired of CVS at approximately 21:15 EDT, 2005.09.20; it was not behaving appropriately. Subsequently, I have migrated my system to use darcs for revision control. This, naturally, presents a small hurdle but, you know, it is for the better in the end. What does not kill you and so on. A good sequence of action follows: 1) Read the docs I wrote for using darcs for rush. These are at http://www.magical-cat.org/projects/rush/rdoc/development.html 2) Download darcs. 3) Get the current source code. 4) Start coding. For the near future, we should exchange patches by e-mail (I will keep updating the 'master' repository available on the web but it is not automated). Eventually (i.e. as soon as a host becomes available) we can switch to use an entirely HTTP-based system which enforces updates slightly better. It might be a good idea to hold off on sending out patches for the next day or two to make sure everyone is getting on board. I do have some work to commit, though: in the event someone would like to see a patch, I can send one. I will try to answer any questions (here or on #rush) as soon as I can. Also, #darcs on freenode, their mailing list and tutorials are very good. Yours, E (rue) From rush-devel-ml at magical-cat.org Fri Sep 23 00:52:52 2005 From: rush-devel-ml at magical-cat.org (ES) Date: Fri, 23 Sep 2005 04:52:52 +0000 Subject: [Rush-developer] Updates & commits & changelogs Message-ID: <43338A24.4060900@magical-cat.org> Hey. Updated the developer documentation a bit: http://www.magical-cat.org/projects/rush/rdoc/#file:doc.HOWTO.development The update actually deals with a crucial omission, the command to update your darcs repository from the website: darcs pull http://... I did some commits so please update either by using darcs (as above, see the docs) or by getting a bundle from: http://www.magical-cat.org/projects/rush/downloads/rush-0.1.bandicoot.developer.tar.gz Also, I generated rdoc for everything under doc/. Please comment on any omissions. http://www.magical-cat.org/projects/rush/rdoc What else... ah. I am trying to work towards a releaseable source tree. There has been some interest in trying rush out. I will flesh out some documentation. Is there anything that absolutely needs to go into such a release (pre-alphaish)? Here is a list of the changes committed. ------------------------------------------------------------- Fri Sep 23 01:28:08 UTC 2005 rue - Eero Saynatkari * 2005.09.22-rue-03 - Revised doc/HOWTO.commands code example. Fri Sep 23 01:19:48 UTC 2005 rue - Eero Saynatkari * 2005.09.22-rue-02 - Revised doc/README. - Wrote doc/HOWTO.commands. - History.save accepts the number of latest lines to save. - Corrected Keys.add in doc/HOWTO.customize. - Fixed .split to .split("\n") for NativeFilter, this was causing weird output (obviously). - fsmanager.rb #requires fsdisk.rb (occasionally needed it seems). - Key#respond_to and Command#respond_to can take either an Array or one or more Strings. Thu Sep 22 17:48:44 UTC 2005 rue - Eero Saynatkari * 2005.09.22-rue-01 - Corrected and added to doc/HOWTO.development. Revised master repository structure (no file structure changes). Wed Sep 21 06:09:33 UTC 2005 rue - Eero Saynatkari * 2005.09.21-rue-01 Initial darcs import. Added doc/HOWTO.development for any info on development practices and using darcs and such. Also, changed the order of doc/CHANGES. ------------------------------------------------------------- Thanks, E (rue) From rush-devel-ml at magical-cat.org Sat Sep 24 04:08:24 2005 From: rush-devel-ml at magical-cat.org (ES) Date: Sat, 24 Sep 2005 08:08:24 +0000 Subject: [Rush-developer] Daily rush update: rubyforge tracker, darcs documents Message-ID: <43350978.2060606@magical-cat.org> Hey. Codewise not much news. Still cleaning up, been a bit busy at work. Still planning to release by the end of the week, code permitting. Updated the RF trackers a bit, any bug report should now send an email notice to this list (though it may need to be approved). Also, added a bit to make handling your code easier in darcs. This went into the 'Making changes' section (also on the web, same address). ================================================================== Before we get to actually making changes, there is one easy technique to make changing the code much easier. There is a tendency for a programmer to do multiple, often unrelated, things (code-wise) at one time and the "hey, let me add this now that I thought of it" apropos fixes and enhancements are prevalent. Mind you, there is nothing wrong with fixing stuff immediately (in fact, it is quite encouraged), it is just that, from a code repository's point of view, big changesets with many unrelated changes are not optimal. It also makes reviewing changelogs and tracking the history of the code less pleasant. (Granted, I am not one to lecture. Just witness my patchwork quilts. -rue) So, to avoid these problems, try to always keep your changesets as small and strictly related as possible --while still ensuring that the code as a whole works after applying that change. For example, you could consider one task or changeset to be 1) adding a new command, 2) fixing one line in all existing commands or 3) reformatting all documentation files. These are fine by themselves whether they use one file or everything in the repository because they are logically grouped. You would not want to mix any two of those together, though. Also, this makes things like fixing bugs much faster since you do not have to wait until your other changes are finished to release the fix. Wanting to do multiple things at once is unavoidable, though, and this is where darcs will help you. Its distributed nature means that there is no central repository (other than what the developers amongst themselves decide); each is equal in its 'capabilities'. We can further extend this idiom by, each individual developer, maintaining one 'master' repository and multiple 'working' repositories (this is why we have $RUSH/master). The master repository should be your window to the world and the other developers: it is where you update others' code from the web and it is where you send your updates to others. The working repositories, on the other hand, are where you write your code. To illustrate the point, assume you want to brush up some of these documentation pieces. First you need to create the working copy. cd into your $RUSH and then: darcs get --verbose ./master ./docfix This creates a new repository docfix (at this time, an exact replica of master) just like you created master from the 'actual' master repository on the web. Then, just start making your changes in docfix. If somewhere along the way you get, say, a bug report from a user and immediately know how to solve it, instead of just starting to work on the fix in docfix, you should create another repository just for that purpose (same procedure as creating docfix). Then you can work on the two independently. Once you have completed and recorded the change you intended (more of which below), you can transfer it back to your master repository. Before doing that, however, you should make sure that the master and your working repository have the same code (other than your new changes) unless you know you have not otherwise updated master. In $RUSH/docfix: darcs pull --verbose ../master This will merge all changes in master that are not in your working repository. After you have merged and resolved any conflicts, you are ready to send in your changes. For this, still in $RUSH/docfix, issue: darcs push --verbose ../master That is all. The repository remembers where it originally was pulled from so your 'docfix' changes are now incorporated into 'master' -in fact, it is exactly as if you had made the changes in 'master'. Then just delete the 'docfix' repository (rm -Rf is fine here) and repeat for any other of your 'working repositories'. ========================================================================== Thanks, E (rue) From rush-devel-ml at magical-cat.org Sun Sep 25 02:46:37 2005 From: rush-devel-ml at magical-cat.org (ES) Date: Sun, 25 Sep 2005 06:46:37 +0000 Subject: [Rush-developer] Daily rush update: changelogs. Message-ID: <433647CD.7080103@magical-cat.org> Hey. Recorded a fair amount of changes. These are available in the 'current' repository on the web. http://www.magical-cat.org/projects/rush/repo/current If you already have a repository, please cd into that repo and update: darcs pull http://www.magical-cat.org/projects/rush/repo/current If you do not have a repository, create a /path/to/rush, cd in and: darcs get http://www.magical-cat.org/projects/rush/repo/current master Did not touch developer docs since yesterday. Please read them if you have not done so. Here is the changelog: ====================================================================== rue, 2005.09.25 02: - Commented and cleaned up commands/*. - commands/pwd.rb uses FsManager. - Command always puts the remaining non-option args in an Array. - cd/pushd defaults. - pushd/popd use FsManager.stack. - FsDisk stores @current_path when .navigating. rue, 2005.09.25 01: - FsDisk.list to list all files and dirs. (I have no idea how this was supposed to work.) rue, 2005.09.24 02: - FsXXX.default_path returns the default for the FS. - FsManager delegates to the FS's using method_missing. - FsDisk implements default_path. - FsDisk implements current_path and current_path=. - Moved $env[:stackd] to FsManager.stack. - bin/rush initializes FsManager to FsDisk with the current dir. - (These may have broken the other FS'. Test/fix later.) rue, 2005.09.24. 01: - pushd/cd and popd functional. - fsmanager.rb initializes $env[:stackd] rue, 2005.09.23 03: - Licence clause in doc/HOWTO.commands. - Sliced doc/TODO from doc/README. - Doc touchups. - Renamed PipelineStopedException to --Stopped--. - Removed tabs from alias.rb. - Attributed metaid.rb to _why. - ^C is a no-op. rue, 2005.09.23 02: - Removed commands/print, to_global and testcommands as useless. rue, 2005.09.23 01: - Documentation revisions. ====================================================================== Thanks, E (rue) From noreply at rubyforge.org Sat Sep 24 02:15:38 2005 From: noreply at rubyforge.org (noreply@rubyforge.org) Date: Sat, 24 Sep 2005 06:15:38 GMT Subject: [Rush-developer] [ rush-Bugs-2513 ] Testing the bug mailing Message-ID: <200509240615.j8O6FcMV031987@rubyforge.org> Bugs item #2513, was opened at 2005-09-24 06:15 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3449&aid=2513&group_id=874 Category: Curses Group: developer Status: Open Resolution: None Priority: 1 Submitted By: Eero Saynatkari (rue) Assigned to: Nobody (None) Summary: Testing the bug mailing Initial Comment: Just making sure this gets e-mailed. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=3449&aid=2513&group_id=874 From rush-devel-ml at magical-cat.org Mon Sep 26 02:57:17 2005 From: rush-devel-ml at magical-cat.org (ES) Date: Mon, 26 Sep 2005 06:57:17 +0000 Subject: [Rush-developer] Daily rush update: ^C breaks, ^D exits + some others. Message-ID: <43379BCD.6060500@magical-cat.org> Hey. Less changes than I hoped today, but updated repo. Same instructions. ====================================================== rue, 2005.09.26 01: - Command#parse_options returns [] for nil args. rue, 2005.09.25 05: - Split break.rb into break.rb (^C) and eof.rb (^D). - Documented both of above. - Parser.break resets the parser for the current cycle (exits Ruby-mode). rue, 2005.09.25 04: - The Ruby return value is #inspect rather than #to_s. rue, 2005.09.25 03: - Parser.split returns sections only, not is_pipe. - Parser.construct_from returns nil for empty String. - Fixed bug with variable name (detail vs. details) in Parser.execute. - Documented parser.rb. ======================================================== Thanks, E (rue) From rush-devel-ml at magical-cat.org Tue Sep 27 06:42:01 2005 From: rush-devel-ml at magical-cat.org (ES) Date: Tue, 27 Sep 2005 10:42:01 +0000 Subject: [Rush-developer] Daily rush update: environment handling + default config Message-ID: <433921F9.7030904@magical-cat.org> Hey. manveru has been working on some commands (hopefully included tomorrow), I worked on this: ===================================================================== rue, 2005.09.27 02: - env.rb abstracts both internal and system env handling. - Changed $env[...] and ENV to $env everywhere. - Added info to doc/HOWTO.using. rue, 2005.09.27 01: - Moved colour initializations from default_config.rb to general.rb to be run at Rush.curses_init. - Changed default prompts and colours. ===================================================================== I added some docs for the new env handling: Two kinds of environment variables exist: system variables (such as HOME or PATH) and rush's internal variables (such as debug). Both kinds can be accessed through the global $env using the format $env., for example $env.HOME or $env.debug. Any uppercase variable is assumed to be a system variable and any lowercase one is assumed to be internal. You can, if you wish, access these variables through the more standard $env['variable'] and $env[:variable] as well (for both the system and the internal ones), but the preferred dot-syntax offers slightly more variation: $env.variable # Returns the current value of variable. $env.variable = 'foo' # Sets variable to 'foo'. $env.variable? # Returns true if the variable exists ('' OK). $env.variable! # Sets variable to true. http://www.magical-cat.org/projects/rush/repo/current is up-to-date. Thanks, E (rue) From rush-devel-ml at magical-cat.org Wed Sep 28 01:10:57 2005 From: rush-devel-ml at magical-cat.org (ES) Date: Wed, 28 Sep 2005 05:10:57 +0000 Subject: [Rush-developer] Daily rush update: lots of Command help, parser change, method completion Message-ID: <433A25E1.7090104@magical-cat.org> Hey. Repository is updated. http://www.magical-cat.org/projects/rush/repo/current/ Current tar is available. http://www.magical-cat.org/projects/rush/downloads/rush-0.1.bandicoot.developer.tar.gz Changes: =========================================================== rue, 2005.09.27 04: - Command.help allows defining three help messages for a command. These are accessible through Cmd.help, Cmd.usage and Cmd.syntax. - Any option with :desc (optional) will have :desc appended to usage. - Command.option can also take parameters (key, name, method, desc in that order) in addition to the Hash. - UsageError can be raised with the command class to automatically print syntax (or usage if no syntax). Can be forced to show usage with a second parameter true). - Basic helps for all commands. - Commands.list shows the @help message (automatically #puts it). - Command has @opts available by default. rue, 2005.09.27 03: - Method completion works on user variables now, too (completion.rb). - Created Parser.eval to abstract out all direct eval calls. - Changed every eval to use it. - Parser.session unavailable outside Parser. ============================================================ Here is the important part about the doc/HOWTO.commands update (read it, please): -------------------------------------------------------------------- Now that the method is implemented, you should offer some information about the command to the user. For this, you can use the class method help_message, which actually takes *three* messages as its three parameters. The first one is just a one-sentence, one-line explanation of what the command does. This one would usually be used in listings such as Commands.list. The second one should be the full-detail usage message. It should be a detailed description and a listing of all options and their descriptions. Two notable things about this: firstly, a 'help' option (-h and --help) is automatically created for you from this message (if you do not want this to happen --why?-- you can just define help separately after you have created help_message). Secondly, any option that defines :help automatically appends that help message at the end of this usage message. (This is the preferred method.) The third one is optional and it provides a syntax message. Ideally, this would include the syntax to invoke the command and a list of the options allowed. If this is defined, it is automatically displayed to the user when a UsageError is raised (otherwise, the long usage message would be used). ----------------------------------------------------------------------- Thanks, E (rue) From rush-devel-ml at magical-cat.org Thu Sep 29 06:16:39 2005 From: rush-devel-ml at magical-cat.org (ES) Date: Thu, 29 Sep 2005 10:16:39 +0000 Subject: [Rush-developer] Daily rush update: command automation Message-ID: <433BBF07.3000806@magical-cat.org> Hey. Did a lot of automation for commands, options and their documentation. Also, manveru has been churning out simple versions of filesystem manipulation commands (those will be in tomorrow). Read doc/HOWTO.commands about the new syntax (or lack thereof). Repository is current. http://www.magical-cat.org/projects/rush/repo/current ======================================================== rue, 2005.09.29 01: - Command#initialize creates @opts before calling parse_options. - Command.option fixed to accept :args positionally. - Command.option automatically generates a default method. - Command#exec processes nil input better. - Corrected HOWTO.commands. ========================================================= Thanks, E (rue) From cmpfixer at hotmail.com Thu Sep 29 07:36:00 2005 From: cmpfixer at hotmail.com (**** * ******) Date: Thu, 29 Sep 2005 07:36:00 -0400 Subject: [Rush-developer] rush env fix Message-ID: dear list, hey. to this message i have attached a rush env fix that defines inspect to redirect to the internal env's inspect. -------------- next part -------------- A non-text attachment was scrubbed... Name: rush-env-fix Type: application/octet-stream Size: 5989 bytes Desc: not available Url : http://rubyforge.org/pipermail/rush-developer/attachments/20050929/027c33ab/rush-env-fix.obj From rush-devel-ml at magical-cat.org Thu Sep 29 13:52:53 2005 From: rush-devel-ml at magical-cat.org (ES) Date: Thu, 29 Sep 2005 17:52:53 +0000 Subject: [Rush-developer] darcs patch: manverus rushtils 0.1 (and 1 more) [Forwarded] Message-ID: <433C29F5.5030401@magical-cat.org> These will be in current shortly. E (rue) -------------- next part -------------- An embedded message was scrubbed... From: manveru at gmail.com Subject: darcs patch: manverus rushtils 0.1 (and 1 more) Date: Thu, 29 Sep 2005 11:49:52 +0200 Size: 17615 Url: http://rubyforge.org/pipermail/rush-developer/attachments/20050929/90c809da/manverusrushtils0-0001.eml