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(
"KOffice script interpreter."),
00044
"2.0.0");
00045
00046 KCmdLineArgs::addCmdLineOptions(options);
00047
00048 KApplication app;
00049
00050 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00051
00052
if (args->count() < 1)
00053 {
00054 fprintf(stderr, i18n(
"You must specify a script.\n").local8Bit());
00055 ::exit(1);
00056 }
00057
00058 qDebug(
"..... KScript started");
00059 {
00060
QStringList argList;
00061
for(
int i = 1; i < args->count(); ++i )
00062 argList.append( args->arg(i) );
00063
00064
KSInterpreter script;
00065 script.
addSearchPath( QDir::currentDirPath() );
00066
QString ex = script.
runScript( args->arg(0), argList );
00067
if ( !ex.isEmpty() )
00068 printf(
"%s\n",ex.local8Bit().data());
00069 }
00070 std::cout << std::endl;
00071
return 0;
00072 }
This file is part of the documentation for lib Library Version 1.3.3.