Project

cmdr

0.0
No commit activity in last 3 years
No release in over 3 years
cmdr
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

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.