Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            args = new[] { "-a", @"C:\Users\willi\odrive\Google Drive\Programming Projects\- C#\Compact Intermediate Bytecode (CIB)\Examples\hello world.casm" };

            ArgumentsTemplate argumentsTemplate = GetArgumentsTemplate();
            Arguments         arguments         = Arguments.Parse(args, (char)KeySelector.Linux);

            if (arguments.Length == 0 || arguments.Keyless.Contains("help"))
            {
                argumentsTemplate.ShowManual(HelpFormatting.ShowVersion); return;
            }

            try
            {
                if (arguments.ContainsKey("a"))
                {
                    // Assemble .casm files
                    VertifyArrayIsPopulated(arguments["a"], "files", "assemble");
                    for (int i = 0; i < arguments["a"].Length; i++)
                    {
                        new Assembler(arguments["a"][i]).Assemble(
                            arguments.ContainsKey("out") ?
                            arguments["out"][0] :
                            Path.GetDirectoryName(arguments["a"][i])
                            );
                    }
                }
                else if (arguments.ContainsKey("d"))
                {
                    // Assemble .casm files
                    VertifyArrayIsPopulated(arguments["d"], "files", "disassemble");
                    for (int i = 0; i < arguments["d"].Length; i++)
                    {
                        new Disassembler(arguments["a"][i]).Disassemble(Console.Out);
                    }
                }
                else
                {
                    // Execute .cib files
                    for (int i = 0; i < arguments.Keyless.Count; i++)
                    {
                        new Interpreter(arguments.Keyless[i]).Interpret();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            args = new[] { "test", "/o", "oooo", "/d", "dddd" };

            Arguments a = Arguments.Parse(args);

            ArgumentsTemplate at = new ArgumentsTemplate(
                new List <ArgumentOption>
            {
                new ArgumentOption("v", "verbose", "Toggle verbose mode.", new List <ArgumentParameter> {
                    new ArgumentParameter("mode", typeof(bool), "", true)
                }),
                new ArgumentOption("e", null, "Use encoding mode to encode a file.", new List <ArgumentParameter> {
                    new ArgumentParameter("lsb", typeof(int))
                }),
                new ArgumentOption("e", null, "Use extended encoding with specified filepath and output.", new List <ArgumentParameter> {
                    new ArgumentParameter("file", typeof(string)),
                    new ArgumentParameter("out", typeof(string)),
                    new ArgumentParameter("debug", typeof(bool), "", true)
                })
            },
                false,
                new List <ArgumentCommand> {
                new ArgumentCommand("encode", "Select mode to encoding. This will encode a message inside the selected file.")
            },
                true,
                new List <ArgumentText> {
                new ArgumentText("Custom title:", new[] { "This text is customizable! You can write anything you want here and all words will wrap correctly, isn't that amazing!!!", "And is supports multiple paragraphs :D" })
            },
                "My Custom Console App",
                (char)KeySelector.CrossPlatformCompatible
                );

            at.ShowManual(HelpFormatting.None);

            Console.Read();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            ColorConsole.ConsoleWriter CConsole = new ColorConsole.ConsoleWriter();
            //args = new[] { "test.wl" };

            Arguments a = Arguments.Parse(args, (char)KeySelector.CrossPlatformCompatible);

            if (a.Keyless.Count > 0)
            {
                bool debug    = a.ContainsKey("d");
                bool comments = debug; // a.ContainsKey("c");

                for (int i = 0; i < a.Keyless.Count; i++)
                {
                    if (File.Exists(a.Keyless[i]))
                    {
                        if (a[i].ToLower().EndsWith(".wl") || a[i].ToLower().EndsWith(".w"))
                        {
                            if (a.Keyless.Count > 1)
                            {
                                if (i != 0)
                                {
                                    Console.Write('\n');
                                }
                                CConsole.WriteLine($"==== {a[i].Split('\\')[a[i].Split('\\').Length - 1]} ====", ConsoleColor.Yellow);
                            }
                            new Interpreter(a[i]).Interpret(debug, comments);

                            // Console.ReadKey(true); // Pause
                        }
                        else
                        {
                            Console.WriteLine($"The file: '{a[i]}' is not a WordLang file!");
                        }
                    }
                    else
                    {
                        Console.WriteLine($"The file: '{a[i]}' was not found!");
                    }
                }
            }
            else
            {
                ArgumentsTemplate at = new ArgumentsTemplate(
                    new System.Collections.Generic.List <ArgumentOption>
                {
                    new ArgumentOption("d", "debug", "Enable debugging.")
                },
                    false,
                    new System.Collections.Generic.List <ArgumentCommand>
                {
                    new ArgumentCommand("[files]", "Files to interpret.")
                },
                    true,
                    null,
                    null,
                    (char)KeySelector.CrossPlatformCompatible
                    );

                at.ShowManual(HelpFormatting.TitleUnderlines);
            }
        }
Ejemplo n.º 4
0
 internal StaticFunction()
     : base(
         (KeyValuePair <string, ParameterType>[])ArgumentsTemplate.Clone(),
         (KeyValuePair <string, ParameterType>[])ResultTemplate.Clone())
 {
 }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            // args = new[] {@"Examples\logging.afk", @"Examples\movie time.afk", @"Examples\program.afk", "/cp"};
            //args = new[] {@"Examples\movie time.afk", @"Examples\program.afk", "/cp"};
            // args = new[] {@"Examples\logging.afk", "/cp", "/hl"};
            // args = new[] {@"Examples\movie time.afk"};

            Arguments a = Arguments.Parse(args);

            childProcesses = a.ContainsKey("cp");
            hideLogging    = a.ContainsKey("hl");
            Cursor         = new Cursor(Cursor.Current.Handle);

            if (a.Keyless.Count > 0)
            {
                string file = a.Keyless[0];
                // Run the first script here
                if (!File.Exists(file))
                {
                    Console.WriteLine($"The script file '{file}' was not found!");
                }
                else
                {
                    if (childProcesses)
                    {
                        Thread t = new Thread(new ParameterizedThreadStart(Run));
                        t.Start(file);
                    }
                    else
                    {
                        Run(file);
                    }
                }
                // Start all other scripts as new processes
                if (a.Keyless.Count > 1)
                {
                    for (int i = 1; i < a.Keyless.Count; i++)
                    {
                        file = a.Keyless[i];
                        if (!File.Exists(file))
                        {
                            Console.WriteLine($"The script file '{file}' was not found!");
                            continue;
                        }

                        if (childProcesses)
                        {
                            Thread t = new Thread(new ParameterizedThreadStart(Run));
                            t.Start(file);
                        }
                        else
                        {
                            Process.Start(Assembly.GetExecutingAssembly().Location, file);
                        }
                    }
                }
            }
            else
            {
                try
                {
                    ArgumentsTemplate at = new ArgumentsTemplate(new List <ArgumentOption>()
                    {
                        new ArgumentOption("cp", "Run all (if multiple) scripts as child processes"),
                        new ArgumentOption("hl", "Hide logging")
                    }, false, new List <ArgumentCommand>()
                    {
                        new ArgumentCommand("file(s)", "The AFK Script file(s) to execute")
                    }, true, new List <ArgumentText>(), "AFK Script", (char)KeySelector.CrossPlatformCompatible);
                    at.ShowManual();
                }
                catch
                {
                    Console.WriteLine("Could not show command line");
                }
            }
            Console.ReadKey(true);
        }