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); } }
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(); }
static void Main(string[] args) { args = new [] { "build", @"C:\Users\willi\Desktop\pond test\config.json" }; Arguments a = Arguments.Parse(args); if (a.ContainsKey("h") || a.ContainsKey("?") || args.Length == 0 || a.Keyless.Count == 0) { At.ShowManual(); } else if (a.Keyless[0] == "init") { // Initialize new Pond project #region Initialize string cd = Directory.GetCurrentDirectory(); string json = JsonConvert.SerializeObject(Config.Default, Formatting.Indented); string configPath = Path.Combine(cd, "config.json"); Console.WriteLine($"Creating {configPath}..."); File.WriteAllText(configPath, json); #region Folders Directory.CreateDirectory(Path.Combine(cd, Config.Default.ArticlesPath)); Directory.CreateDirectory(Path.Combine(cd, Config.Default.TemplatesPath)); Directory.CreateDirectory(Path.Combine(cd, Config.Default.StylesPath)); Directory.CreateDirectory(Path.Combine(cd, Config.Default.OutputPath)); #endregion string buildPath = Path.Combine(cd, "build.bat"); Console.WriteLine($"Creating {buildPath}..."); File.WriteAllText(buildPath, $@"@echo off Pond build ""{configPath}"" pause "); Console.WriteLine("Done. Project was successfully initialized!", ConsoleColor.Green); #endregion } else if (a.Keyless.Count >= 2 && a.Keyless[0] == "build") { // Run Pond #region Build string configDirectory = Path.GetDirectoryName(a.Keyless[1]); Console.WriteLine("Building project...", ConsoleColor.Yellow); Config config = LoadConfig(a); if (config != null) { PondCompiler.Compile(configDirectory, config, Debug); Console.WriteLine("Done. Website was successfully built!", ConsoleColor.Green); } else { Console.WriteLine("Could not load config!", ConsoleColor.Red); } #endregion } else { Console.WriteLine("Unknown command, please use /? or /h for more help.", ConsoleColor.Red); } }
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); } }
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); }