Fix bug with classes, use slim exclusively, add package private data and change rehaul cmake configs
This commit is contained in:
@@ -6,153 +6,150 @@
|
||||
using namespace Tesses::Framework;
|
||||
using namespace Tesses::Framework::Http;
|
||||
|
||||
namespace Tesses::CrossLang::Programs
|
||||
{
|
||||
namespace Tesses::CrossLang::Programs {
|
||||
|
||||
static bool Download(Tesses::Framework::Filesystem::VFSPath filename,std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs)
|
||||
{
|
||||
auto inContainer=Platform::Environment::GetVariable("CROSSLANG_CONTAINER");
|
||||
if(inContainer && (*inContainer=="1" || *inContainer=="y" || *inContainer=="Y"))
|
||||
{
|
||||
static bool Download(Tesses::Framework::Filesystem::VFSPath filename,
|
||||
std::shared_ptr<Tesses::Framework::Filesystem::VFS> vfs) {
|
||||
auto inContainer =
|
||||
Platform::Environment::GetVariable("CROSSLANG_CONTAINER");
|
||||
if (inContainer &&
|
||||
(*inContainer == "1" || *inContainer == "y" || *inContainer == "Y")) {
|
||||
HttpRequest req;
|
||||
req.followRedirects=true;
|
||||
req.followRedirects = true;
|
||||
req.url = "https://redirect.tesses.net/crosslang-shell";
|
||||
req.method = "GET";
|
||||
HttpResponse resp(req);
|
||||
if(resp.statusCode == StatusCode::OK)
|
||||
{
|
||||
if (resp.statusCode == StatusCode::OK) {
|
||||
auto strm = resp.ReadAsStream();
|
||||
CrossLang::CrossArchiveExtract(strm, vfs);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error when fetching the script error: " << std::to_string(resp.statusCode) << " " << HttpUtils::StatusCodeString(resp.statusCode) << std::endl;
|
||||
} else {
|
||||
std::cout << "Error when fetching the script error: "
|
||||
<< std::to_string(resp.statusCode) << " "
|
||||
<< HttpUtils::StatusCodeString(resp.statusCode)
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
while(true)
|
||||
{
|
||||
std::cout << "File " << filename.ToString() << " not found, do you want to download the installer from: https://redirect.tesses.net/crosslang-shell (this may install other stuff as well) (Y/n)? ";
|
||||
while (true) {
|
||||
std::cout << "File " << filename.ToString()
|
||||
<< " not found, do you want to download the installer from: "
|
||||
"https://redirect.tesses.net/crosslang-shell (this may "
|
||||
"install other stuff as well) (Y/n)? ";
|
||||
std::string line;
|
||||
std::getline(std::cin,line);
|
||||
if(line == "Y" || line == "y")
|
||||
{
|
||||
std::getline(std::cin, line);
|
||||
if (line == "Y" || line == "y") {
|
||||
HttpRequest req;
|
||||
req.followRedirects = true;
|
||||
req.url = "https://redirect.tesses.net/crosslang-shell";
|
||||
req.method = "GET";
|
||||
HttpResponse resp(req);
|
||||
if(resp.statusCode == StatusCode::OK)
|
||||
{
|
||||
if (resp.statusCode == StatusCode::OK) {
|
||||
auto strm = resp.ReadAsStream();
|
||||
CrossLang::CrossArchiveExtract(strm, vfs);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error when fetching the script error: " << std::to_string(resp.statusCode) << " " << HttpUtils::StatusCodeString(resp.statusCode) << std::endl;
|
||||
} else {
|
||||
std::cout << "Error when fetching the script error: "
|
||||
<< std::to_string(resp.statusCode) << " "
|
||||
<< HttpUtils::StatusCodeString(resp.statusCode)
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(line == "N" || line == "n")
|
||||
{
|
||||
std::cout << "Looks like you will need to install manually" << std::endl;
|
||||
} else if (line == "N" || line == "n") {
|
||||
std::cout << "Looks like you will need to install manually"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
std::cout << "Please use Y or N (case insensitive)" << std::endl;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TObject CrossLangShell(GCList& ls, std::vector<std::string>& argv)
|
||||
{
|
||||
TObject CrossLangShell(GCList &ls, std::vector<std::string> &argv) {
|
||||
|
||||
Tesses::Framework::Filesystem::VFSPath dir = GetCrossLangConfigDir();
|
||||
|
||||
Tesses::Framework::Filesystem::VFSPath filename = dir / "Shell" / "Shell.crvm";
|
||||
Tesses::Framework::Filesystem::VFSPath filename =
|
||||
dir / "Shell" / "Shell.crvm";
|
||||
|
||||
|
||||
auto p = Tesses::Framework::Platform::Environment::GetRealExecutablePath(Tesses::Framework::Filesystem::LocalFS->SystemToVFSPath(argv[0])).GetParent().GetParent() / "share" / "Tesses" / "CrossLang" / "Tesses.CrossLang.ShellPackage-1.0.0.0-prod.crvm";
|
||||
if(argv.size() == 2 && argv[1] == "configdir")
|
||||
{
|
||||
auto p =
|
||||
Tesses::Framework::Platform::Environment::GetRealExecutablePath(
|
||||
Tesses::Framework::Filesystem::LocalFS->SystemToVFSPath(argv[0]))
|
||||
.GetParent()
|
||||
.GetParent() /
|
||||
"share" / "Tesses" / "CrossLang" /
|
||||
"Tesses.CrossLang.ShellPackage-1.0.0.0-prod.crvm";
|
||||
if (argv.size() == 2 && argv[1] == "configdir") {
|
||||
std::cout << dir.ToString() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
if(argv.size() > 1 && argv[1] == "update-shell")
|
||||
{
|
||||
if (argv.size() > 1 && argv[1] == "update-shell") {
|
||||
|
||||
auto subdir = std::make_shared<Tesses::Framework::Filesystem::SubdirFilesystem>(Tesses::Framework::Filesystem::LocalFS,dir);
|
||||
auto subdir =
|
||||
std::make_shared<Tesses::Framework::Filesystem::SubdirFilesystem>(
|
||||
Tesses::Framework::Filesystem::LocalFS, dir);
|
||||
HttpRequest req;
|
||||
req.followRedirects=true;
|
||||
req.url = "https://redirect.tesses.net/crosslang-shell";
|
||||
req.method = "GET";
|
||||
HttpResponse resp(req);
|
||||
if(resp.statusCode == StatusCode::OK)
|
||||
{
|
||||
auto strm = resp.ReadAsStream();
|
||||
CrossLang::CrossArchiveExtract(strm, subdir);
|
||||
req.followRedirects = true;
|
||||
req.url = "https://redirect.tesses.net/crosslang-shell";
|
||||
req.method = "GET";
|
||||
HttpResponse resp(req);
|
||||
if (resp.statusCode == StatusCode::OK) {
|
||||
auto strm = resp.ReadAsStream();
|
||||
CrossLang::CrossArchiveExtract(strm, subdir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error when fetching the script error: " << std::to_string(resp.statusCode) << " " << HttpUtils::StatusCodeString(resp.statusCode) << std::endl;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
std::cout << "Error when fetching the script error: "
|
||||
<< std::to_string(resp.statusCode) << " "
|
||||
<< HttpUtils::StatusCodeString(resp.statusCode)
|
||||
<< std::endl;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!Tesses::Framework::Filesystem::LocalFS->RegularFileExists(filename))
|
||||
{
|
||||
auto subdir = std::make_shared<Tesses::Framework::Filesystem::SubdirFilesystem>(Tesses::Framework::Filesystem::LocalFS,dir);
|
||||
if(Tesses::Framework::Filesystem::LocalFS->RegularFileExists(p))
|
||||
{
|
||||
std::cout << "Installing " << p.ToString() << " -> " << dir.ToString() << std::endl;
|
||||
auto strm = Tesses::Framework::Filesystem::LocalFS->OpenFile(p,"rb");
|
||||
if(strm != nullptr)
|
||||
{
|
||||
if (!Tesses::Framework::Filesystem::LocalFS->RegularFileExists(filename)) {
|
||||
auto subdir =
|
||||
std::make_shared<Tesses::Framework::Filesystem::SubdirFilesystem>(
|
||||
Tesses::Framework::Filesystem::LocalFS, dir);
|
||||
if (Tesses::Framework::Filesystem::LocalFS->RegularFileExists(p)) {
|
||||
std::cout << "Installing " << p.ToString() << " -> "
|
||||
<< dir.ToString() << std::endl;
|
||||
auto strm =
|
||||
Tesses::Framework::Filesystem::LocalFS->OpenFile(p, "rb");
|
||||
if (strm != nullptr) {
|
||||
CrossLang::CrossArchiveExtract(strm, subdir);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!Download(filename,subdir)) return 1;
|
||||
} else {
|
||||
if (!Download(filename, subdir))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
TRootEnvironment *env =
|
||||
TRootEnvironment::Create(ls, TDictionary::Create(ls));
|
||||
|
||||
TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls));
|
||||
TStd::RegisterStd(ls.GetGC(), env);
|
||||
|
||||
env->LoadFileWithDependencies(
|
||||
ls.GetGC(), Tesses::Framework::Filesystem::LocalFS, filename);
|
||||
|
||||
TStd::RegisterStd(ls.GetGC(),env);
|
||||
|
||||
|
||||
env->LoadFileWithDependencies(ls.GetGC(), Tesses::Framework::Filesystem::LocalFS, filename);
|
||||
|
||||
|
||||
TList* args = TList::Create(ls);
|
||||
TList *args = TList::Create(ls);
|
||||
|
||||
args->Add(filename.ToString());
|
||||
|
||||
for(size_t arg=1;arg<argv.size();arg++)
|
||||
for (size_t arg = 1; arg < argv.size(); arg++)
|
||||
args->Add(std::string(argv[arg]));
|
||||
|
||||
return env->CallFunctionWithFatalError(ls,"main",{args});
|
||||
|
||||
return env->CallFunctionWithFatalError(ls, "main", {args});
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Tesses::CrossLang::Programs
|
||||
|
||||
Reference in New Issue
Block a user