/// <summary> /// The main entry point for the PowerShell Modular Input /// </summary> /// <param name="args">The arguments</param> public static void Main(string[] args) { // log our command line Console.Error.WriteLine("INFO: PowerShell.exe " + string.Join(" ", args)); // configure the logger XmlFormatter.LogOutputErrors = Settings.Default.LogOutputErrors; XmlFormatter.OutputBlanksOnError = Settings.Default.OutputBlanksOnError; XmlFormatter.Logger = new ConsoleLogger(); XDocument document = null; XElement input = null; if (args.Length > 0) { if (args[0].ToLower().Equals("--scheme")) { WriteScheme(); Environment.Exit(0); } else if (args[0].ToLowerInvariant().Equals("--validate_arguments")) { Console.Error.Write( "ERROR: --validate_arguments not implemented yet"); Environment.Exit(1); } else if (args[0].ToLowerInvariant().Equals("--input") && args.Length == 2) { // Logger.WriteLog(LogLevel.Info, "Reading InputDefinition from parameter for testing"); document = XDocument.Load(args[1]); } else { Console.Error.Write("ERROR: " + Usage); Environment.Exit(2); } } else { document = XDocument.Parse(Console.In.ReadToEnd()); } try { Console.Error.Write("DEBUG: " + document); input = document.Element("input"); if (input == null) { Console.Error.Write("ERROR: input is not valid input xml"); Environment.Exit(6); } } catch (Exception ex) { Console.Error.Write("ERROR: input is not valid input xml: " + ex.Message); Environment.Exit(6); } var self = new ModularPowerShell(input, XmlFormatter.Logger); self.StartScheduler(); }
/// <summary> /// The main entry point for the PowerShell Modular Input /// </summary> /// <param name="args">The arguments</param> public static void Main(string[] args) { // log our command line DebugLog.Debug(PowerShellExe + " " + string.Join(" ", args)); // configure the logger XmlFormatter.LogOutputErrors = Settings.Default.LogOutputErrors; XmlFormatter.OutputBlanksOnError = Settings.Default.OutputBlanksOnError; XmlFormatter.Logger = new ConsoleLogger(); XDocument document = null; XElement input = null; if (args.Length > 0) { if (args[0].ToLower().Equals("--scheme")) { WriteScheme(); Environment.Exit(0); } else if (args[0].ToLowerInvariant().Equals("--validate_arguments")) { DebugLog.Fatal("--validate_arguments not implemented yet"); Environment.Exit(1); } else if (args[0].ToLowerInvariant().Equals("--input") && args.Length == 2) { // Logger.WriteLog(LogLevel.Info, "Reading InputDefinition from parameter for testing"); var path = System.IO.Path.GetFullPath(args[1]); if (!System.IO.File.Exists(path)) { DebugLog.Fatal("Input file not found: " + path); Environment.Exit(4); } document = XDocument.Load(path); } else { DebugLog.Fatal(string.Format(Usage, PowerShellExe)); Environment.Exit(2); } } else { document = XDocument.Parse(Console.In.ReadToEnd()); } try { input = document.Element("input"); if (input == null) { DebugLog.Fatal("input is not valid input xml: no root input element"); Environment.Exit(6); } } catch (Exception ex) { DebugLog.Fatal("input is not valid input xml: " + ex.Message); Environment.Exit(6); } var self = new ModularPowerShell(input, XmlFormatter.Logger); self.StartScheduler(); }