mirror of
https://onedev.site.tesses.net/crosslang/crosslangextras
synced 2026-02-09 01:25:46 +00:00
41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
Plaintext
func Tesses.CrossLang.Shell.Console(dd)
|
|
{
|
|
var dir = Env.CrossLangConfig / "ConsoleApps";
|
|
if(dd.Arguments.Length == 1)
|
|
{
|
|
Console.WriteLine("List of console applications:");
|
|
if(FS.Local.DirectoryExists(dir))
|
|
each(var item : FS.Local.EnumeratePaths(dir))
|
|
{
|
|
Console.WriteLine(Tesses.CrossLang.GetNameAndDescription(item / item.GetFileName() + ".crvm"));
|
|
}
|
|
return 0;
|
|
}
|
|
else if(dd.Arguments.Length >= 2)
|
|
{
|
|
var consolename = dd.Arguments[1];
|
|
var consolepath = dir / consolename / consolename + ".crvm";
|
|
|
|
if(FS.Local.FileExists(consolepath))
|
|
{
|
|
|
|
var env = VM.CreateEnvironment({});
|
|
env.RegisterEverything();
|
|
env.LockRegister();
|
|
|
|
env.LoadFileWithDependencies(FS.Local,consolepath);
|
|
var myArgs = [];
|
|
myArgs.Add(consolepath.ToString());
|
|
for(var i = 2; i < dd.Arguments.Count; i++)
|
|
{
|
|
myArgs.Add(dd.Arguments[i]);
|
|
}
|
|
return env.GetDictionary().main(myArgs);
|
|
}
|
|
else {
|
|
Console.WriteLine($"Could not find console application with name {consolename}.");
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
} |