Example #1
0
        public static Task <int> MainCore(string[] args, HttpSource httpSource, ILogger log)
        {
#if DEBUG
            if (args.Contains("--debug"))
            {
                args = args.Skip(1).ToArray();
                while (!Debugger.IsAttached)
                {
                }

                Debugger.Break();
            }
#endif

            var assemblyVersion = NuGetVersion.Parse(typeof(Program).GetTypeInfo().Assembly.GetName().Version.ToString());

            var app = new CommandLineApplication()
            {
                Name     = "NuGet.CatalogValidator",
                FullName = "nuget mirror"
            };
            app.HelpOption(Constants.HelpOption);
            app.VersionOption("--version", assemblyVersion.ToNormalizedString());
            app.Description = "Validate a nuget v3 feed.";

            Configure();

            ValidateCommand.Register(app, httpSource, log);

            app.OnExecute(() =>
            {
                app.ShowHelp();

                return(0);
            });

            var exitCode = 0;

            try
            {
                exitCode = app.Execute(args);
            }
            catch (CommandParsingException ex)
            {
                ex.Command.ShowHelp();
            }
            catch (Exception ex)
            {
                exitCode = 1;

                LogException(ex, log);
            }

            return(Task.FromResult(exitCode));
        }
Example #2
0
        public static Task <int> MainCore(string[] args, HttpSource httpSource, ILogger log)
        {
            CmdUtils.LaunchDebuggerIfSet(ref args, log);

            var app = new CommandLineApplication()
            {
                Name     = "NuGet.CatalogValidator",
                FullName = "nuget mirror"
            };

            app.HelpOption(Constants.HelpOption);
            app.VersionOption("--version", (new NuGetVersion(CmdUtils.GetAssemblyVersion())).ToNormalizedString());
            app.Description = "Validate a nuget v3 feed.";

            Configure();

            ValidateCommand.Register(app, httpSource, log);

            app.OnExecute(() =>
            {
                app.ShowHelp();
                return(1);
            });

            var exitCode = 1;

            try
            {
                exitCode = app.Execute(args);
            }
            catch (CommandParsingException ex)
            {
                ex.Command.ShowHelp();
            }
            catch (Exception ex)
            {
                ExceptionUtils.LogException(ex, log);
            }

            return(Task.FromResult(exitCode));
        }