On Fri, Apr 1, 2016 at 11:45 AM, sebb <seb...@gmail.com> wrote: > On 1 April 2016 at 16:09, Sam Ruby <ru...@intertwingly.net> wrote: >> On Fri, Apr 1, 2016 at 10:42 AM, Craig Russell <craig.russ...@oracle.com> >> wrote: >> >>> 4. Could this be called directly from the command line, e.g. ruby >>> views/actions/memstat clr emeritus >> >> Directly? No. But it is quite possible to write a script that sets a >> few instance variables and then reads and evals the script. The tests >> for the board agenda tool do this: >> >> https://github.com/apache/whimsy/blob/master/www/board/agenda/spec/actions_spec.rb#L40 > > Is it not possible to add a section of the form: > > if __FILE__ == $0 > @uid = ARGV[0] > @state = ARGV[1] > eval(File.read(__FILE__)) # or some other invocation method > end
That indeed could be added to the top of the file, without the eval. - Sam Ruby