in Source/NuGetGallery.Operations.Tools/Program.cs [45:98]
public int Invoke(string[] args)
{
try
{
HelpCommand = new HelpCommand(Manager, "galops", "NuGet Gallery Operations", "https://github.com/NuGet/NuGetOperations/wiki/GalOps---Gallery-Operations-Commands");
// Add commands
foreach (ICommand cmd in Commands)
{
Manager.RegisterCommand(cmd);
}
// Parse the command
var parser = new CommandLineParser(Manager);
ICommand command = parser.ParseCommandLine(args) ?? HelpCommand;
// Fall back on help command if we failed to parse a valid command
if (!ArgumentCountValid(command))
{
string commandName = command.CommandAttribute.CommandName;
Console.WriteLine("{0}: invalid arguments..", commandName);
HelpCommand.ViewHelpForCommand(commandName);
}
else
{
command.Execute();
}
}
catch (AggregateException exception)
{
string message;
Exception unwrappedEx = ExceptionUtility.Unwrap(exception);
if (unwrappedEx == exception)
{
// If the AggregateException contains more than one InnerException, it cannot be unwrapped. In which case, simply print out individual error messages
message = String.Join(Environment.NewLine, exception.InnerExceptions.Select(ex => ex.Message).Distinct(StringComparer.CurrentCulture));
}
else
{
message = ExceptionUtility.Unwrap(exception).Message;
}
_logger.Error("{0}: {1}", unwrappedEx.GetType().Name, message);
_logger.Error(" Stack Trace: " + unwrappedEx.StackTrace);
return 1;
}
catch (Exception e)
{
var ex = ExceptionUtility.Unwrap(e);
_logger.Error("{0}: {1}", ex.GetType().Name, ex.Message);
_logger.Error(" Stack Trace: " + ex.StackTrace);
return 1;
}
return 0;
}