static void Main(string[] args) { // Define environment bool isExecuted = false; bool isVersionSet = false; List <string> configLoop = new List <string>(args); List <string> commandLoop = new List <string>(); API.Phantom.OutputEncoding = "UTF-8"; API.Phantom.CookiesEnabled = true; Program.args = args; #if DEBUG Program.verbose = true; #endif // Check OS Support CheckSupport(); // No arguments? Run in interactive mode. if (args.Length < 1) { Interactive(); return; } // Config Loop (Set IE version etc) foreach (string arg in configLoop) { string[] parts = arg.Split('='); switch (parts[0]) { case "-?": case "/?": case "-h": case "--help": Help(); return; case "--debug": Program.verbose = true; break; case "-v": case "--version": var v = API.Phantom.Version; Console.WriteLine("{0}.{1}.{2}", v["major"], v["minor"], v["patch"]); return; case "--emulate": isVersionSet = Browser.Emulate(arg.Replace("--emulate=", "").ToUpper()); break; case "--proxy": Proxy.server = arg.Replace("--proxy=", ""); break; case "--proxy-auth": Proxy.auth = arg.Replace("--proxy-auth=", ""); break; case "--proxy-type": Proxy.type = arg.Replace("--proxy-type=", ""); break; case "--ignore-ssl-errors": if (arg.Replace("--ignore-ssl-errors=", "").ToLower().Equals("true")) { // TODO } break; default: commandLoop.Add(arg); break; } } // Default to IE9 if (!isVersionSet) { Browser.Emulate("IE9"); } // Set proxy information if needed if (!String.IsNullOrEmpty(Proxy.server)) { Proxy.Set(); } // Command Loop - Execution foreach (string arg in commandLoop) { string[] parts = arg.Split('='); switch (parts[0]) { case "-t": case "--test": Test(); return; case "--render": string url = arg.Replace("--render=", ""); Render(url); return; default: // If no switch is defined then we are dealing // with javascript files that need executing if (arg == parts[0] && !isExecuted) { Open(arg); isExecuted = true; } else if (parts[0].StartsWith("--")) { Help(); Exit(0); } break; } } Exit(0); }
static void Main(string[] args) { // Commence Program.Args = args; #if DEBUG Program.Verbose = true; Utils.Debug("{0} {1}", AppDomain.CurrentDomain.FriendlyName, String.Join(" ", args)); #endif // Define environment bool isExecuted = false; bool isVersionSet = false; bool optClearCache = false; List <string> configLoop = new List <string>(args); List <string> commandLoop = new List <string>(); API.Phantom.outputEncoding = "UTF-8"; API.Phantom.cookiesEnabled = true; API.Phantom.libraryPath = Environment.CurrentDirectory; // Check OS Support CheckSupport(); // No arguments? Run in interactive mode. if (args.Length < 1) { Interactive(); return; } // Config Loop (Set IE version etc) foreach (string arg in configLoop) { string[] parts = arg.Split('='); switch (parts[0]) { case "-?": case "/?": case "-h": case "--help": Help(); return; case "--debug": Program.Verbose = arg.Replace("--debug=", "").ToLower() != "false"; break; case "-v": case "--version": var v = API.Trifle.Version; Console.WriteLine("{0}.{1}.{2}", v["major"], v["minor"], v["patch"]); return; case "--emulate": isVersionSet = Browser.Emulate(arg.Replace("--emulate=", "").ToUpper()); break; case "--output-encoding": API.Phantom.outputEncoding = arg.Replace("--output-encoding=", ""); break; case "--script-encoding": API.Phantom.scriptEncoding = arg.Replace("--script-encoding=", ""); break; case "--clear-cache": optClearCache = true; break; case "--paranoid-mode": Program.ParanoidMode = true; break; case "--proxy": Proxy.server = arg.Replace("--proxy=", ""); break; case "--proxy-auth": Proxy.auth = arg.Replace("--proxy-auth=", ""); break; case "--proxy-type": Proxy.type = arg.Replace("--proxy-type=", ""); break; case "--ignore-ssl-errors": if (arg.Replace("--ignore-ssl-errors=", "").ToLower().Equals("true")) { API.Trifle.IgnoreSSLErrors = true; } break; default: commandLoop.Add(arg); break; } } // Clear cache? if (optClearCache) { API.Console.xdebug("Clearing IE Cache History..."); Native.CacheHelper.ClearCache(false); } // Default to Installed Version if (!isVersionSet) { String version = Browser.InstalledVersion(); if (!String.IsNullOrEmpty(version)) { Browser.Emulate(version); } else { // No version? use IE7 Browser.Emulate("IE7"); } } // Set proxy information if needed if (!String.IsNullOrEmpty(Proxy.server)) { Proxy.Set(); } // Command Loop - Execution foreach (string arg in commandLoop) { string[] parts = arg.Split('='); switch (parts[0]) { case "-u": case "--unit-test": UnitTest(); Exit(0); return; case "-p": case "--phantom-test": PhantomTest(); Exit(0); return; case "--render": string url = arg.Replace("--render=", ""); Render(url); return; default: // If no switch is defined then we are dealing // with javascript files that need executing if (arg == parts[0] && !isExecuted) { Open(arg); isExecuted = true; } else if (parts[0].StartsWith("--")) { Help(); Exit(0); } break; } } Exit(0); }
static void Main(string[] args) { // Define environment bool isExecuted = false; bool isVersionSet = false; List <string> configLoop = new List <string>(args); List <string> commandLoop = new List <string>(); API.Phantom.OutputEncoding = "UTF-8"; API.Phantom.CookiesEnabled = true; Program.args = args; #if DEBUG Program.verbose = true; #endif // No arguments? Run in interactive mode. if (args.Length < 1) { Interactive(); return; } // Config Loop (Set IE version etc) foreach (string arg in configLoop) { string[] parts = arg.Split(':'); switch (parts[0]) { case "-?": case "/?": case "-h": case "--help": Help(); return; case "--debug": Program.verbose = true; break; case "-v": case "--version": var v = API.Phantom.Version; Console.WriteLine("{0}.{1}.{2}", v["major"], v["minor"], v["patch"]); return; case "--emulate": string version = arg.Replace("--emulate:", ""); try { Browser.Emulate(version.ToUpper()); isVersionSet = true; } catch { Console.Error.WriteLine(String.Format("Unrecognized IE Version \"{0}\". Choose from \"IE7\", \"IE8\", \"IE9\", \"IE10\".", version)); } break; default: commandLoop.Add(arg); break; } } // Default to IE9 if (!isVersionSet) { Browser.Emulate("IE9"); } // Command Loop - Execution foreach (string arg in commandLoop) { string[] parts = arg.Split(':'); switch (parts[0]) { case "-t": case "--test": Test(); return; case "--render": string url = arg.Replace("--render:", ""); Render(url); return; default: // If no switch is defined then we are dealing // with javascript files that need executing if (arg == parts[0] && !isExecuted) { Open(arg); isExecuted = true; } else if (parts[0].StartsWith("--")) { Help(); Exit(0); } break; } } Exit(0); }