diff --git a/Tesses.CrossLang.Args/cross.json b/Tesses.CrossLang.Args/cross.json new file mode 100644 index 0000000..efafa11 --- /dev/null +++ b/Tesses.CrossLang.Args/cross.json @@ -0,0 +1,11 @@ +{ + "name": "Tesses.CrossLang.Args", + "version": "1.0.0.0-prod", + "info": { + "maintainer": "Mike Nolan", + "type": "lib", + "repo": "https://gitea.site.tesses.net/tesses50/crosslang/crosslang-libs", + "homepage": "https://crosslang.tesseslanguage.com/", + "license": "LGPLv3" + } +} \ No newline at end of file diff --git a/Tesses.CrossLang.Args/src/args.tcross b/Tesses.CrossLang.Args/src/args.tcross new file mode 100644 index 0000000..f97e9de --- /dev/null +++ b/Tesses.CrossLang.Args/src/args.tcross @@ -0,0 +1,39 @@ +func Tesses.CrossLang.Args(args) +{ + var filename = args[0]; + + if(args.Count < 1) return null; + var flags = []; + var options = []; + var pos = []; + + var onlyPos=false; + + for(var i = 1; i < args.Count; i++) + { + if(args[i] == "--") { + onlyPos=true; + continue; + } + if(!onlyPos && args[i].Count > 2 && args[i][0] == '-' && args[i][1] == '-') + { + var p = args[i].Substring(2).Split("=",true,2); + if(p.Count == 1) + flags.Add(p[0]); + else if(p.Count == 2) + options.Add({Key = p[0],Value=p[1]}); + } + else { + pos.Add(args[i]); + } + } + + + return { + Options = options, + FileName = filename, + Flags = flags, + Arguments = pos + }; + +} \ No newline at end of file diff --git a/Tesses.CrossLang.BuildEssentials/src/buildtool.tcross b/Tesses.CrossLang.BuildEssentials/src/buildtool.tcross index f9ef94f..b31879d 100644 --- a/Tesses.CrossLang.BuildEssentials/src/buildtool.tcross +++ b/Tesses.CrossLang.BuildEssentials/src/buildtool.tcross @@ -51,7 +51,6 @@ func Tesses.CrossLang.BuildTool(pm) }; }, BuildProject = (this,projectDirectory)=>{ - var dir = FS.MakeFull(projectDirectory); var dirStr = dir.ToString(); @@ -99,10 +98,12 @@ func Tesses.CrossLang.BuildTool(pm) { each(var dep : configData.project_dependencies) { - if(dep.IsRelative()) - dependencies.Add(this.BuildProject(dir / dep)); + if(Path.FromString(dep).IsRelative()) + { + dependencies.Add(this.BuildProject((dir / dep))); + + } else - dependencies.Add(this.BuildProject(dep)); } } diff --git a/Tesses.CrossLang.Shell/cross.json b/Tesses.CrossLang.Shell/cross.json index 8747f15..d390224 100644 --- a/Tesses.CrossLang.Shell/cross.json +++ b/Tesses.CrossLang.Shell/cross.json @@ -9,6 +9,7 @@ "license": "LGPLv3" }, "project_dependencies": [ - "./Tesses.CrossLang.BuildEssentials" + "../Tesses.CrossLang.BuildEssentials", + "../Tesses.CrossLang.Args" ] } \ No newline at end of file diff --git a/Tesses.CrossLang.Shell/src/main.tcross b/Tesses.CrossLang.Shell/src/main.tcross index d293a86..babd799 100644 --- a/Tesses.CrossLang.Shell/src/main.tcross +++ b/Tesses.CrossLang.Shell/src/main.tcross @@ -1,4 +1,64 @@ func main(args) { - Console.WriteLine("Hello, world"); + var dd = Tesses.CrossLang.Args(args); + if(dd.Arguments.Count > 0) + { + var commandName = dd.Arguments[0]; + if(commandName == "args") + { + each(var arg : dd.Arguments) + { + Console.WriteLine(arg); + } + } + if(commandName == "build") + { + var offline=false; + var buildPath = "."; + if(dd.Arguments.Count > 1) + { + buildPath = dd.Arguments[1]; + } + each(var flag : dd.Flags) + { + if(flag == "offline") + { + offline = true; + } + } + var pm = Tesses.CrossLang.PackageManager(); + pm.Offline = offline; + var bt = Tesses.CrossLang.BuildTool(pm); + bt.BuildProject(buildPath); + } + else if(commandName == "run") + { + var offline=false; + var buildPath = "."; + + each(var flag : dd.Flags) + { + if(flag == "offline") + { + offline = true; + } + } + var pm = Tesses.CrossLang.PackageManager(); + pm.Offline = offline; + var bt = Tesses.CrossLang.BuildTool(pm); + var output = bt.BuildProject(buildPath).Output; + + var env = VM.CreateEnvironment({}); + env.RegisterEverything(); + env.LockRegister(); + + env.LoadFileWithDependencies(FS.Local,output); + var myArgs = []; + for(var i = 1; i < dd.Arguments.Count; i++) + { + myArgs.Add(dd.Arguments[i]); + } + return env.GetDictionary().main(myArgs); + } + } } \ No newline at end of file diff --git a/script.sh b/script.sh index 416e3a5..4724061 100755 --- a/script.sh +++ b/script.sh @@ -1,3 +1,5 @@ #!/bin/bash cd Tesses.CrossLang.BuildEssentials && crossc -o ./bin-tmp -n Tesses.CrossLang.BuildEssentials -v 1.0.0.0-prod main.tcross src/*.tcross && cd .. -crossvm ./Tesses.CrossLang.BuildEssentials/bin-tmp/Tesses.CrossLang.BuildEssentials-1.0.0.0-prod.crvm Tesses.CrossLang.Shell \ No newline at end of file +crossvm ./Tesses.CrossLang.BuildEssentials/bin-tmp/Tesses.CrossLang.BuildEssentials-1.0.0.0-prod.crvm Tesses.CrossLang.Shell +crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Tesses.CrossLang.PackageServer +#crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Tesses.CrossLang.Website \ No newline at end of file