Esempio n. 1
0
        static void Main(string[] args)
        {
            Source.Hello();
            Compile.Hello();
            Dirry.InitAltDrives();
            Instruction.Init();
            MKL.Version("Wendicka Project - WASM_Main.cs", "20.03.01");
            MKL.Lic("Wendicka Project - WASM_Main.cs", "GNU General Public License 3");
            Console.WriteLine($"Wendicka Assembler {MKL.Newest} - (c) {MKL.CYear(2020)} Jeroen P. Broks\n");
            if (args.Length == 0)
            {
                Console.WriteLine("Usage: WASM [options] <File>");
                TrickyDebug.AttachWait();
                return;
            }
            var parse = new FlagParse(args);

            parse.CrBool("s", false);
            parse.Parse();
            Silence = parse.GetBool("s");
            foreach (string f in parse.Args)
            {
                Compile.Go(Dirry.AD(f).Replace("\\", "/"));
            }
            Console.WriteLine($"\tErrors: {Errors}; Warnings: {Warnings}");
            TrickyDebug.AttachWait();
        }
Esempio n. 2
0
 void Init(string[] args)
 {
     Kthura.automap = false;
     if (args.Length == 0)
     {
         Uitleg();
         OriCol();
         Environment.Exit(0);
     }
     InitJCR6.Go();
     ExportBasis.Init();
     Dirry.InitAltDrives(AltDrivePlaforms.Windows); // TODO: I may need to expand this later for Linux and Mac.
     cli_Settings = new FlagParse(args);
     cli_Settings.CrString("target");
     cli_Settings.CrString("project");
     cli_Settings.CrString("map");
     cli_Settings.CrString("xpto");
     if (!cli_Settings.Parse())
     {
         Uitleg();
         Error("Parsing command line input failed!");
     }
     Project = cli_Settings.GetString("project");
     Map     = cli_Settings.GetString("map");
     XPTo    = cli_Settings.GetString("xpto");
     Target  = cli_Settings.GetString("target");
     Assert(File.Exists(GlobalConfigFile), $"I cannot find {GlobalConfigFile}");
     GlobalConfig = GINI.ReadFromFile(GlobalConfigFile);
     Assert(GlobalConfig != null, "Global config could nt be properly loaded");
     Assert(Project, "Hey! I don't have a project!");
     Assert(WorkSpace, "I can't find out what the workspace is. Is Kthura properly configured?");
     Assert(File.Exists(ProjectConfigFile), $"I could not access {ProjectConfigFile}. It appears it doesn't exist!");
     Doing("Reading project", ProjectConfigFile);
     ProjectConfig = GINI.ReadFromFile(ProjectConfigFile);
     Assert(ProjectConfig, "Project could not be properly read.");
     Target = cli_Settings.GetString("target");
     if (Target == "")
     {
         Target = ProjectConfig.C("EXPORT.TARGET");
     }
     Assert(Target, "No target");
     Doing("Exporting to", Target);
     Assert(ExportBasis.HaveDriver(Target), $"Driver to export to {Target} has not been found!");
     XPTo = cli_Settings.GetString("xpto");
     if (XPTo == "")
     {
         XPTo = ProjectConfig.C("EXPORT.XPTO");
     }
     Assert(XPTo, "No export-to folder.");
     Map = cli_Settings.GetString("map");
 }
Esempio n. 3
0
 private Program(string[] args)
 {
     fp = new FlagParse(args);
     Dirry.InitAltDrives();
     MKL.Lic("Alternate Dir - Program.cs", "GNU General Public License 3");
     MKL.Version("Alternate Dir - Program.cs", "19.10.27");
     fp.CrBool("p", false);
     fp.CrBool("all", false);
     fp.CrBool("ansi", OnWindows);
     fp.CrBool("s", false);
     fp.CrBool("w", false);
     fp.CrBool("b", false);
     fp.CrBool("h", false);
     fp.Parse();
 }
Esempio n. 4
0
        static void Run(string[] args)
        {
            var f = new FlagParse(args);

            if (args.Length == 0)
            {
                QCol.White("\tUsage: ");
                QCol.Cyan($"{qstr.StripDir(MKL.MyExe)} ");
                QCol.Green("<command> ");
                QCol.Yellow("<parameters>\n\n");
                var tabx = 5;
                foreach (string k in Features.Keys)
                {
                    if (k.Length > tabx)
                    {
                        tabx = k.Length;
                    }
                }
                foreach (string k in Features.Keys)
                {
                    QCol.Green(k);
                    for (int i = k.Length; i < tabx + 2; ++i)
                    {
                        Console.Write(" ");
                    }
                    QCol.Yellow($"{Features[k].Description}\n");
                }
                return;
            }
            var cmd = args[0].ToUpper();

            if (!Features.ContainsKey(cmd))
            {
                QCol.QuickError($"Command '{cmd}' has not been understood");
                return;
            }
            Features[cmd].Parse(f);
            if (!f.Parse())
            {
                QCol.QuickError($"Bad command line input");
                return;
            }
            Features[cmd].Run(f);
        }
Esempio n. 5
0
        void SetupProject(string[] args)
        {
            dwriteln("Project setup started");
            FlagParse fp = new FlagParse(args);

            fp.CrString("Target", "");
            fp.CrString("To", "");
            fp.CrString("Project", "");
            if (!fp.Parse(
#if DEBUG
                    true
#endif
                    ))
            {
                Crash("Flag parsing failed!");
            }
            XProject = fp.GetString("Project");
            XTarget  = fp.GetString("Target");
            XTo      = fp.GetString("To");
            if (XProject == "" && XTarget == "" && XTo == "")
            {
                cwrite(ConsoleColor.Cyan, "Usage: ");
                cwrite(ConsoleColor.DarkGreen, $"{qstr.RemSuffix(qstr.StripDir(System.Reflection.Assembly.GetEntryAssembly().Location),".exe")} ");
                cwrite(ConsoleColor.DarkMagenta, "-<flag> <value>\n\n");
                cwrite(ConsoleColor.Red, string.Format("{0,15}", "-Project ")); cwriteln(ConsoleColor.Green, "Define the project");
                cwrite(ConsoleColor.Red, string.Format("{0,15}", "-Target ")); cwriteln(ConsoleColor.Green, "Define the target language");
                cwrite(ConsoleColor.Red, string.Format("{0,15}", "-To ")); cwriteln(ConsoleColor.Green, "Define the folder where the translations should go to");
                Console.WriteLine("");
                cwriteln(ConsoleColor.Yellow, "Supported target languages:");
                foreach (string drv in XPort_Base.Drivers.Keys)
                {
                    cwrite(ConsoleColor.Red, "= ");
                    cwriteln(ConsoleColor.DarkYellow, drv);
                }
                Console.WriteLine("");
                cwriteln(ConsoleColor.White, "Please note that \"To\" and \"Target\" can also be defined in the project file, so you don't have to name them here.\nWhen using them here on the cli even if set in the project file, the value set in the cli will take priority!");
                Halt(0);
            }
            if (XProject == "")
            {
                Crash("No Project!");
            }
            ProjectFile = Dirry.AD($"{MainConfig.C("WorkSpace")}/{XProject}/{XProject}.project.GINI");
            dwriteln($"Reading: {ProjectFile}");
            ProjectConfig = GINI.ReadFromFile(ProjectFile);
            cwrite(ConsoleColor.Yellow, "Reading Project: ");
            cwriteln(ConsoleColor.Cyan, XProject);
            if (ProjectConfig == null)
            {
                Crash($"Reading {ProjectFile} failed!");
            }
            if (XTarget == "")
            {
                XTarget = ProjectConfig.C("XPORT.TARGET");
            }
            if (XTarget == "")
            {
                Crash("And to what language do you want to translate this to? Without the -Target flag, I don't know!");
            }
            if (XTo == "")
            {
                XTo = ProjectConfig.C("XPORT.TO");
            }
            if (XTo == "")
            {
                Crash("And where do you want the translations to be put? Without the -To flag, I don't know!");
            }
            XTarget = XTarget.ToLower();
            if (!XPort_Base.Drivers.ContainsKey(XTarget))
            {
                Crash($"I cannot export to {XTarget}");
            }
        }
Esempio n. 6
0
 private static void InitArgs()
 {
     JCR6_lzma.Init();
     MyArgs.CrBool("version", false);
     MyArgs.CrBool("help", false);
     MyArgs.CrBool("h", false);
     if (!MyArgs.Parse(true))
     {
         throw new Exception("Invalid input");
     }
     if (MyArgs.GetBool("version"))
     {
         Head();
         Console.WriteLine(MKL.All(true));
         Environment.Exit(0);
     }
     if (MyArgs.GetBool("h") || MyArgs.GetBool("help"))
     {
         Head();
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.Write("MKL_Update ");
         Console.ForegroundColor = ConsoleColor.Yellow;
         Console.WriteLine("[<dir1> [<dir2> [<dir3>....]]]");
         Console.ForegroundColor = ConsoleColor.Gray;
         Console.WriteLine("\tUpdates the MKL data and license blocks in given directories. If none given, the current directory will be done");
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.Write("MKL_Update ");
         Console.ForegroundColor = ConsoleColor.Magenta;
         Console.WriteLine("-h");
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.Write("MKL_Update ");
         Console.ForegroundColor = ConsoleColor.Magenta;
         Console.WriteLine("-help");
         Console.ForegroundColor = ConsoleColor.Gray;
         Console.WriteLine("\tShows this help text");
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.Write("MKL_Update ");
         Console.ForegroundColor = ConsoleColor.Magenta;
         Console.WriteLine("-version");
         Console.ForegroundColor = ConsoleColor.Gray;
         Console.WriteLine("\tShows detailed version information");
         Console.WriteLine("\n\n\nThe next programming languages are supported by MKL_Update");
         foreach (string k in JCR.Entries.Keys)
         {
             if (qstr.Prefixed(k, "EXT/"))
             {
                 TGINI T = GINI.ReadFromLines(JCR.ReadLines(k));
                 // Console.WriteLine($"{k} => {qstr.Prefixed(k, "EXT/")}"); // debug line
                 Console.ForegroundColor = ConsoleColor.Yellow;
                 Console.BackgroundColor = ConsoleColor.Blue;
                 Console.Write(k.ToLower());
                 for (int i = k.Length; i < 30; i++)
                 {
                     Console.Write(" ");
                 }
                 Console.BackgroundColor = ConsoleColor.Black;
                 Console.ForegroundColor = ConsoleColor.Magenta;
                 Console.WriteLine($" {T.C("LANGUAGE")}");
             }
         }
         Console.ResetColor();
         Environment.Exit(0);
     }
 }