/// <summary> /// The main entry point for the application. /// </summary> private static int Main(string[] args) { ProgramUtils.Init(); using var handler = new CliCommandHandler(); return((int)ProgramUtils.Run(ExeName, args, handler)); }
/// <summary> /// The main entry point for the application. /// </summary> private static int Main(string[] args) { ProgramUtils.Init(); using var handler = new CliCommandHandler(); return((int)ProgramUtils.Run("0install", args.Prepend(Run.Name), handler)); }
/// <summary> /// The main entry point for the application. /// </summary> private static int Main(string[] args) { ProgramUtils.Init(); using (var handler = new CliCommandHandler()) return (int)ProgramUtils.Run(ExeName, args, handler); }
private static void ForEachCommand(Action<CliCommand> action) { using (var handler = new CliCommandHandler()) { foreach (string commandName in CommandFactory.CommandNames) { var command = CommandFactory.GetCommand(commandName, handler); var multiCommand = command as MultiCommand; if (multiCommand == null) action(command); else { foreach (string stringCommandName in multiCommand.SubCommandNames) action(multiCommand.GetCommand(stringCommandName)); } } } }
private static void ForEachCommand(Action <CliCommand> action) { using var handler = new CliCommandHandler(); foreach (string commandName in CliCommand.Names) { var command = CliCommand.Create(commandName, handler); if (command is CliMultiCommand multiCommand) { foreach (string stringCommandName in multiCommand.SubCommandNames) { action(multiCommand.GetCommand(stringCommandName)); } } else { action(command); } } }
/// <summary> /// Runs the application (called by main method or by embedding process). /// </summary> public static ExitCode Run(string[] args) { var handler = new CliCommandHandler(); try { var command = new StoreMan(handler); command.Parse(args); return(command.Execute()); } #region Error handling catch (OperationCanceledException) { return(ExitCode.UserCanceled); } catch (NeedGuiException ex) { if (ProgramUtils.GuiAssemblyName == null) { Log.Error(ex); return(ExitCode.InvalidArguments); } else { Log.Info("Switching to GUI"); try { return((ExitCode)ProcessUtils.Assembly(ProgramUtils.GuiAssemblyName, args.Prepend(StoreMan.Name)).Run()); } #region Error handling catch (OperationCanceledException) { return(ExitCode.UserCanceled); } catch (IOException ex2) { Log.Error(ex2); return(ExitCode.IOError); } #endregion } } catch (NotAdminException ex) { if (WindowsUtils.IsWindowsNT) { try { return((ExitCode)ProcessUtils.Assembly(ProgramUtils.GuiAssemblyName ?? "0install", args.Prepend(StoreMan.Name)).AsAdmin().Run()); } #region Error handling catch (OperationCanceledException) { return(ExitCode.UserCanceled); } catch (IOException ex2) { Log.Error(ex2); return(ExitCode.IOError); } #endregion } else { Log.Error(ex); return(ExitCode.AccessDenied); } } catch (OptionException ex) { var builder = new StringBuilder(ex.Message); if (ex.InnerException != null) { builder.Append("\n" + ex.InnerException.Message); } builder.Append("\n" + string.Format(Resources.TryHelp, ExeName)); Log.Error(builder.ToString()); return(ExitCode.InvalidArguments); } catch (FormatException ex) { Log.Error(ex); return(ExitCode.InvalidArguments); } catch (WebException ex) { Log.Error(ex); return(ExitCode.WebError); } catch (NotSupportedException ex) { Log.Error(ex); return(ExitCode.NotSupported); } catch (IOException ex) { Log.Error(ex); return(ExitCode.IOError); } catch (UnauthorizedAccessException ex) { Log.Error(ex); return(ExitCode.AccessDenied); } catch (InvalidDataException ex) { Log.Error(ex); return(ExitCode.InvalidData); } catch (SignatureException ex) { Log.Error(ex); return(ExitCode.InvalidSignature); } catch (DigestMismatchException ex) { Log.Error(ex); return(ExitCode.DigestMismatch); } #endregion finally { handler.CloseUI(); } }
/// <summary> /// Runs the application (called by main method or by embedding process). /// </summary> public static ExitCode Run(string[] args) { var handler = new CliCommandHandler(); try { var command = CommandFactory.CreateAndParse(args, handler); return command.Execute(); } #region Error handling catch (OperationCanceledException) { return ExitCode.UserCanceled; } catch (NeedGuiException ex) { if (ProgramUtils.GuiAssemblyName == null) { Log.Error(ex); return ExitCode.InvalidArguments; } else { Log.Info("Switching to GUI"); try { return (ExitCode)ProcessUtils.Assembly(ProgramUtils.GuiAssemblyName, args).Run(); } #region Error handling catch (OperationCanceledException) { return ExitCode.UserCanceled; } catch (IOException ex2) { Log.Error(ex2); return ExitCode.IOError; } #endregion } } catch (NotAdminException ex) { try { return (ExitCode)ProcessUtils.Assembly(ProgramUtils.GuiAssemblyName ?? ExeName, args).AsAdmin().Run(); } catch (OperationCanceledException) { return ExitCode.UserCanceled; } catch (PlatformNotSupportedException) { Log.Error(ex); return ExitCode.AccessDenied; } catch (IOException) { Log.Error(ex); return ExitCode.AccessDenied; } } catch (OptionException ex) { Log.Error(ex); Log.Error(string.Format(Resources.TryHelp, ExeName)); return ExitCode.InvalidArguments; } catch (FormatException ex) { Log.Error(ex); return ExitCode.InvalidArguments; } catch (WebException ex) { Log.Error(ex); return ExitCode.WebError; } catch (NotSupportedException ex) { Log.Error(ex); return ExitCode.NotSupported; } catch (IOException ex) { Log.Error(ex); return ExitCode.IOError; } catch (UnauthorizedAccessException ex) { Log.Error(ex); return ExitCode.AccessDenied; } catch (InvalidDataException ex) { Log.Error(ex); return ExitCode.InvalidData; } catch (SignatureException ex) { Log.Error(ex); return ExitCode.InvalidSignature; } catch (DigestMismatchException ex) { Log.Error(ex); return ExitCode.DigestMismatch; } catch (SolverException ex) { Log.Error(ex); return ExitCode.SolverError; } catch (ExecutorException ex) { Log.Error(ex); return ExitCode.ExecutorError; } catch (ConflictException ex) { Log.Error(ex); return ExitCode.Conflict; } #endregion finally { handler.CloseUI(); } }