// main.cpp
// This file is part of the EScript programming language.
// See copyright notice in EScript.h
// ------------------------------------------------------
#ifdef ES_BUILD_APPLICATION
#include <cstdlib>
#include <iostream>
#include <string>

#include "../EScript/EScript.h"

using namespace EScript;

int main(int argc,char * argv[]) {

	if(argc<2){
		std::cout << ES_VERSION<<"\nNo filename given.\n";
		return EXIT_SUCCESS;
	}

	EScript::init();
	ERef<Runtime> rt(new Runtime());

	// --- Set program parameters
	declareConstant(rt->getGlobals(),"args",Array::create(argc,argv));

	// --- Load and execute script
	std::pair<bool,ObjRef> result = EScript::loadAndExecute(*rt.get(),argv[1]);

	// --- output result
	if (!result.second.isNull()) {
		std::cout << "\n\n --- "<<"\nResult: " << result.second.toString()<<"\n";
	}

	return result.first ? EXIT_SUCCESS : EXIT_FAILURE;
}
#endif // ES_BUILD_APPLICATION

// main.cpp
// This file is part of the EScript programming language.
// See copyright notice in EScript.h
// ------------------------------------------------------
#ifdef ES_BUILD_APPLICATION
#include <cstdlib>
#include <iostream>
#include <string>
#include <utility>

#include "../EScript/EScript.h"

int main(int argc, char * argv[]) {
	EScript::init();
	EScript::ERef<EScript::Runtime> rt(new EScript::Runtime());

	// --- Set program parameters
	declareConstant(rt->getGlobals(), "args", EScript::Array::create(argc, argv));

	// --- Load and execute script
	std::pair<bool, EScript::ObjRef> result;
	if(argc == 1) {
		result = EScript::executeStream(*rt.get(), std::cin);
	} else {
		result = EScript::loadAndExecute(*rt.get(), argv[1]);
	}

	// --- output result
	if(!result.second.isNull()) {
		std::cout << "\n\n --- " << "\nResult: " << result.second.toString() << "\n";
	}

	return result.first ? EXIT_SUCCESS : EXIT_FAILURE;
}

#endif // ES_BUILD_APPLICATION

Change EScript application to support executing a string from a pipe/from stdin.
Change EScript application to support executing a string from a pipe/from stdin.

git-svn-id: 5176f51f660287824ea2012221d52a93094db7fd@194 5693b1fc-3b75-4070-9b6b-3ce3692a40d5
