Cmdr is a command-line appication container for executing rscript code from S-Rscript
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
MIT-LICENSE
README.md
cmdr.gemspec
gem-public_cert.pem

README.md

Introducing the cmdr gem

require 'cmdr'

h = {
  alias: {
    'time' => 'rcscript //job:time http://rscript.rorbuilder.info/packages/utility.rsf',
    'plo' => 'rcscript //job:password-lookup http://rscript.rorbuilder.info/packages/utility.rsf'
  }, 
  user: 
  {'-1' => 
    {history: 
      {list: [], index: []}
    }
  }
}

cmdr = Cmdr.new(public: h, config: {bottom_up_display: false})
r = cmdr.run_cmd 'time'
#=> "<?xml version="1.0" encoding="UTF-8"?>
<result>
  <summary>
    <status>success</status>
    <script>
      <![CDATA[
olist = document.getElementById('list');
ocontent = document.getElementById('content');  
oli = document.createElement('li');

oli.innerHTML = "2010-08-10 14:14:55 +0100";
ocontent.insertBefore(oli, ocontent.firstChild);

olist.scrollTop = olist.scrollHeight;

ocommandInput = document.getElementById('user_input');
ocommandInput.value = '';

]]>
    </script>
    <output></output>
  </summary>
  <records/>
</result>
"

r = cmdr.run_cmd 'plo apple'
#=> "<?xml version="1.0" encoding="UTF-8"?>
<result>
  <summary>
    <status>success</status>
    <script>
      <![CDATA[
olist = document.getElementById('list');
ocontent = document.getElementById('content');  
oli = document.createElement('li');

oli.innerHTML = "your password is 4h55QfuJ";
ocontent.insertBefore(oli, ocontent.firstChild);

olist.scrollTop = olist.scrollHeight;

ocommandInput = document.getElementById('user_input');
ocommandInput.value = '';

]]>
    </script>
    <output></output>
  </summary>
  <records/>
</result>
"
h[:user]['-1'][:history][:list]
#=> ["time", "plo apple"]

The cmdr gem is designed for use with Sinatrajax to run rscript code from a web page but with the convenience of the command-line.