summaryrefslogtreecommitdiffstats
path: root/kjsembed/stdlib/cmdline.js
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/stdlib/cmdline.js
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kjsembed/stdlib/cmdline.js')
-rwxr-xr-xkjsembed/stdlib/cmdline.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/kjsembed/stdlib/cmdline.js b/kjsembed/stdlib/cmdline.js
new file mode 100755
index 00000000..9c96c6cb
--- /dev/null
+++ b/kjsembed/stdlib/cmdline.js
@@ -0,0 +1,78 @@
+#!/usr/bin/env kjscmd
+
+function list(obj)
+{
+ println( obj );
+
+ for ( var i in obj ) {
+ try {
+ tp = typeof obj[i];
+
+ count = 20 - i.length;
+ spc = '';
+ for ( var s=0; s < count; s++ )
+ spc = spc + ' ';
+
+ println( ' ' + i + spc + tp );
+ }
+ catch(err) {
+ println( ' ' + i + spc + 'Error, ' + err );
+ }
+ }
+}
+
+function help()
+{
+ println();
+ println( 'KJSCmd ' + part.versionString + ' Prompt' );
+ println( '=======' + '===' + '=======' );
+ println();
+ println( "Type 'quit' to exit, and 'help' for this text. Anything else" );
+ println( 'is evaluated by the KJSCmd engine and the result displayed.' );
+ println();
+}
+
+function cmd_prompt()
+{
+ System.stdout.print( 'kjscmd> ' );
+ return System.stdin.readLine();
+}
+
+//
+// Main
+//
+
+println( "KJSCmd " + part.versionString + " (type 'help' for more information)" );
+done = false;
+
+do {
+
+ line = cmd_prompt();
+
+ if ( line == 'quit' ) {
+ done = true;
+ }
+ else if ( line == 'help' ) {
+ help();
+ }
+ else if ( line == '' ) {
+ // DO NOTHING
+ }
+ else if ( line == null ) {
+ done = true;
+ }
+ else {
+ try {
+ output = eval( line );
+
+ if ( typeof(output) != 'undefined' )
+ println( output );
+ }
+ catch(err) {
+ println( 'Error: ' + err );
+ }
+ }
+
+} while ( !done );
+
+System.exit(0);