예제 #1
0
        public static async Task Execute(string[] args)
        {
            LogConfigurator.EnableConsoleTarget(LogConfigurator.FriendlyLayout, LogLevel.Info);
            LogConfigurator.EnableSentryTarget("https://[email protected]/7");
            LogConfigurator.EnableFileTarget(LogLevel.Trace);

            var container = ContainerBuilder.Container;

            IAppGetUpdateService updatedService = null;

            try
            {
                updatedService = container.Resolve <IAppGetUpdateService>();
                updatedService.Start();


                var commandExecutor = container.Resolve <ICommandExecutor>();
                await commandExecutor.ExecuteCommand(args);
            }
            finally
            {
                if (updatedService != null)
                {
                    await updatedService.Commit();
                }
            }
        }
예제 #2
0
        private static async Task <int> Run(string[] args)
        {
            IAppGetUpdateService updatedService = null;

            try
            {
                var container = ContainerBuilder.Container;

                LogConfigurator.EnableConsoleTarget(LogConfigurator.FriendlyLayout, LogLevel.Info);
                LogConfigurator.EnableSentryTarget("https://[email protected]/7");
                LogConfigurator.EnableFileTarget(LogLevel.Trace);

                try
                {
                    updatedService = container.Resolve <IAppGetUpdateService>();
                    updatedService.Start();
                }
                catch (Exception e)
                {
                    Logger.Error(e, "Failed to initilize update service.");
                }

                if (Debugger.IsAttached && !args.Any())
                {
                    args = TakeArgsFromInput().SkipWhile(c => c.ToLowerInvariant() == "appget").ToArray();
                }

                var commandExecutor = container.Resolve <ICommandExecutor>();
                await commandExecutor.ExecuteCommand(args);

                return(0);
            }
            catch (CommandLineParserException)
            {
                return(1);
            }
            catch (PackageNotFoundException e)
            {
                Logger.Warn(e.Message);

                if (e.Similar.Any())
                {
                    Console.WriteLine("");
                    Console.WriteLine("Suggestions:");
                    e.Similar.ShowTable();
                }

                return(1);
            }
            catch (AppGetException ex)
            {
                Logger.Error(ex, null);

                return(1);
            }
            catch (NotImplementedException ex)
            {
                Logger.Error(ex, null);
                return(1);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex, null);
                return(1);
            }
            finally
            {
                if (updatedService != null)
                {
                    await updatedService.Commit();
                }
            }
        }
예제 #3
0
        private static async Task <int> Run(string[] args)
        {
            IAppGetUpdateService updatedService = null;

            try
            {
                var container = ContainerBuilder.Container;

                LogConfigurator.EnableConsoleTarget(LogConfigurator.FriendlyLayout, LogLevel.Info);
                LogConfigurator.EnableFileTarget(LogLevel.Trace);

                try
                {
                    updatedService = container.Resolve <IAppGetUpdateService>();
                    updatedService.Start();
                }
                catch (Exception e)
                {
                    Logger.Error(e, "Failed to initilize update service.");
                }

                if (Debugger.IsAttached && !args.Any())
                {
                    args = TakeArgsFromInput().SkipWhile(c => c.ToLowerInvariant() == "appget").ToArray();
                }

                Logger.Warn("Thank you for all your support!");
                Logger.Warn("AppGet is no longer maintained and is shutting down. You should probably look into WinGet ;)");
                Logger.Warn("See https://appget.net for more details.");

                return(404);
            }
            catch (CommandLineParserException)
            {
                return(1);
            }
            catch (PackageNotFoundException e)
            {
                Logger.Warn(e.Message);

                if (e.Similar.Any())
                {
                    Console.WriteLine("");
                    Console.WriteLine("Suggestions:");
                    e.Similar.ShowTable();
                }

                return(1);
            }
            catch (AppGetException ex)
            {
                Logger.Error(ex, null);

                return(1);
            }
            catch (NotImplementedException ex)
            {
                Logger.Error(ex, null);
                return(1);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex, null);
                return(1);
            }
            finally
            {
                if (updatedService != null)
                {
                    await updatedService.Commit();
                }
            }
        }