Cookie Consent by FreePrivacyPolicy.com TIBET
TIBET Logo

TIBET

TIBET Shell

TIBET Shell (TSH)


Wins

  • Powerful object-oriented scripting with a tag-based command set.
  • Access data via URL, pipe it, filter it, transform it, and redirect it to the UI.
  • Seamless integration with application code by embedding command tags.
  • Fully-integrated with the TIBET CLI. Access TSH from CLI and vice versa.
  • Easily extensible using a common development paradigm -- custom tags.

Contents

Concepts

Cookbook

Code

Concepts

As developers we've always found it invaluable to have an interactive command line we could use for debugging and experimentation - a 'workspace' in Smalltalk terms.

One of the first things we built in JavaScript was an interactive console for evaluating JavaScript; nothing else existed circa 1997 ;). Simply eval'ing JS is pretty limited though, so over the intervening years we added features like history, aliases, variables, etc.

Eventually we found ourselves wanting a way to extend the shell's command set. By that point we were starting to view tags as macros and we realized the entire system could be unified via smart tags. The modern TSH was born.

TSH is a command interpreter whose normalized input form is XML tags. When used interactively command input is heavily sugared so you are unaware of the XML.

As an example, the following TSH command fetches the project's tibet.json file, formats it as a fully-expanded string, converts it into an html:textarea, and sets that textarea as the content of the element in the current UICANVAS whose id is target:

~app/tibet.json .| :as 'string' .| 'html:textarea' .> #target

As the previous example shows, TSH treats URIs as native objects, allowing you type them in directly and access their content via intelligent content types. TIBET's Content type hierarchy has built-in support for JSON, XML, and a number of specific text-based MIME types.

Because it normalizes as XML tags you can embed TSH scripts in your TIBET UI and trigger them via signals, allowing you to build up scripts interactively and leverage them in your applications with minimal effort. Here's the prior script in current TSH XML format:

<tsh:script>
    <tsh:uri tsh:pipe=".|" tsh:href="~app/tibet.json" />
    <tsh:as tsh:pipe=".|" tsh:argv="'string'"/>
    <tsh:eval tsh:pipe=".>"><![CDATA['html:textarea']]></tsh:eval>
    <tsh:uri tsh:href="#target"/>
</tsh:script>

Below we show an example of using TSH to pluck a slot out of XML content found in one of TIBET's package files.

In the sample below ~app_cfg is a reference to the current configuration variable path.app_cfg (usually public/TIBET-INF/cfg in your TIBET project) so ~app_cfg/t2.xml is a portable reference to public/TIBET-INF/cfg/t2.xml. We access that file and pipe its content providing just a string which works as a property to be accessed, in this case the data slot of the object in the pipe.

NOTE: all of TIBET's pipe operations are asynchronous. Joining the various steps is handled automatically by TSH. Errors are handled by any stderr pipes on your command line.

TSH XML URL Pipe
Sample URL Pipe

TSH provides a built-in set of commands which you can view using :help. Note that some commands are currently placeholders for planned functionality.

TSH Help
TSH Help

In the sample above all built-in TSH commands appear to start with a colon (:). In truth, they are all tags in the tsh namespace. The tsh namespace is the default for interactive TSH, so the full names of the commands are tsh:clear, tsh:help, and so on.

You can create your own commands simply by constructing one or more tags in your own namespace(s) and ensuring they implement common TSH execution methods.

Cookbook

Coming soon…

Code

The primary shell types are found in the ~lib/src/tibet/shells directory, in particular in the source files for the TP.core.Shell and TP.core.TSH types.

Built-in shell commands are found in those files and follow a naming convention of execute*. For example, the built-in :source command which loads a type's source code file, is found in the executeSource method.

Additional commands are constructed as "action tags" in TIBET terminology and can be found in ~lib/src/tsh. Loadable command tags at the time of this writing include:

TP.tsh.apropos.js
TP.tsh.as.js
TP.tsh.audit.js
TP.tsh.bookmark.js
TP.tsh.build.js
TP.tsh.colors.js
TP.tsh.deploy.js
TP.tsh.doclint.js
TP.tsh.dump.js
TP.tsh.echo.js
TP.tsh.edit.js
TP.tsh.entity.js
TP.tsh.eval.js
TP.tsh.export.js
TP.tsh.halo.js
TP.tsh.history.js
TP.tsh.import.js
TP.tsh.inspect.js
TP.tsh.interests.js
TP.tsh.keys.js
TP.tsh.method
TP.tsh.open.js
TP.tsh.package.js
TP.tsh.pp.js
TP.tsh.pull.js
TP.tsh.push.js
TP.tsh.reflect.js
TP.tsh.screen.js
TP.tsh.script.js
TP.tsh.snippet.js
TP.tsh.test.js
TP.tsh.tidy.js
TP.tsh.type
TP.tsh.types.js
TP.tsh.uri.js
TP.tsh.validate.js
TP.tsh.xpath.js
TP.tsh.xslt.js