public static void Main(string[] args) { options = GetOptions(args); var telemetryClient = CreateTelemetryClient(ApplicationInsightsKey, options.NoMetrics); try { if (!string.IsNullOrEmpty(options.OutputFolder) && options.OutputFolder.Contains("\"")) { telemetryClient.TrackEvent("DisplayParameters/OutputPath"); Console.WriteLine("ERROR: The OutputPath (-o) parameter was provided with a trailing backslash. Please remove the trailing backslash and try again."); DisplayParameters(); return; } if (options.LastParserState != null && options.LastParserState.Errors.Any()) { telemetryClient.TrackEvent("DisplayParameters/All"); DisplayParameters(); return; } // Check we have at least been passed a server name if (string.IsNullOrEmpty(options.SqlServerName)) { return; } var stopwatch = Stopwatch.StartNew(); var generatorTask = RunGeneratorAsync(); Task.WaitAll(generatorTask); stopwatch.Stop(); elapsedMilliseconds = stopwatch.ElapsedMilliseconds; telemetryClient.TrackEvent("Executed"); telemetryClient.TrackMetric("Execution Duration", stopwatch.ElapsedMilliseconds); } finally { telemetryClient.Flush(); if (elapsedMilliseconds.HasValue) { PrintOnlyIfVerbose($"Total execution time: {elapsedMilliseconds} ms"); } } }
private static Options GetOptions(string[] args) { var parsedOptions = new Options(); try { if (!Parser.Default.ParseArguments(args, parsedOptions)) { return parsedOptions; } } catch (ParserException ex) { Console.WriteLine($"{Environment.NewLine}Microsoft.ALMRangers.RMWorkflowMigrator: Parameter error"); Console.WriteLine(ex.Message); if (ex.InnerException != null) { Console.WriteLine(ex.InnerException.Message); } } return parsedOptions; }