koscript/main.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "koscript.h"
00021
00022 #include <kapplication.h>
00023 #include <klocale.h>
00024 #include <kcmdlineargs.h>
00025 #include <dcopclient.h>
00026 #include <qstring.h>
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <qdir.h>
00030 #include <iostream>
00031
00032 static KCmdLineOptions options[] =
00033 {
00034 { "+script", I18N_NOOP("Script to run"), 0 },
00035 { "+-- [options]", I18N_NOOP("Options to pass to the script"), 0 },
00036 KCmdLineLastOption
00037 };
00038
00039 int main( int argc, char** argv )
00040 {
00041 const char *appName = (argc > 1) ? argv[1] : "koscript";
00042 KCmdLineArgs::init(argc, argv, appName,
00043 I18N_NOOP("KoScript"),
00044 I18N_NOOP("KOffice script interpreter."),
00045 "2.0.0");
00046
00047 KCmdLineArgs::addCmdLineOptions(options);
00048
00049 KApplication app;
00050
00051 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00052
00053 if (args->count() < 1)
00054 {
00055 fprintf(stderr, "%s", i18n("You must specify a script.\n").local8Bit().data());
00056 ::exit(1);
00057 }
00058
00059 qDebug("..... KScript started");
00060 {
00061 QStringList argList;
00062 for( int i = 1; i < args->count(); ++i )
00063 argList.append( args->arg(i) );
00064
00065 KSInterpreter script;
00066 script.addSearchPath( QDir::currentDirPath() );
00067 QString ex = script.runScript( args->arg(0), argList );
00068 if ( !ex.isEmpty() )
00069 printf("%s\n",ex.local8Bit().data());
00070 }
00071 std::cout << std::endl;
00072 return 0;
00073 }
This file is part of the documentation for lib Library Version 1.4.2.