Пример #1
0
        public void Basic(string[] args, AssertBasic assert)
        {
            CommanderParser <Basic> p = new CommanderParser <Basic>();

            Basic b = p.Parse(args);

            assert(b);
        }
Пример #2
0
        public static async Task Main(string[] args)
        {
            var parser = new CommanderParser <Options>();

            try
            {
                var options = parser.Parse(args);
                await RunAsync(options);
            }
            catch (ParameterMissingException)
            {
                Console.WriteLine(parser.Usage());
            }
        }
Пример #3
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("BansheeBlog updater\n");
            var parser = new CommanderParser <CommandLineArgs>();

            Console.WriteLine(parser.Usage());

            CommandLineArgs parsedArgs;

            try
            {
                parsedArgs = parser.Parse();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return;
            }

            if (parsedArgs.Check != null)
            {
                Console.WriteLine("Check is not yet supported");
            }
            else if (parsedArgs.Install != null || parsedArgs.WaitAndInstall != null)
            {
                var wait        = parsedArgs.WaitAndInstall != null;
                var installArgs = wait ? parsedArgs.WaitAndInstall : parsedArgs.Install;

                var updateDir  = installArgs.UpdateDirectory;
                var backendDir = installArgs.BackendDirectory;
                var publicDir  = installArgs.PublicDirectory;

                if (!Directory.Exists(updateDir) || !Directory.Exists(backendDir) || !Directory.Exists(publicDir))
                {
                    Console.WriteLine("One or more of the required directories does not exist");
                    return;
                }


                if (wait)
                {
                    Console.WriteLine("Waiting for BansheeBlog to exit...");
                    await AwaitServerShutdown(backendDir);
                }

                try
                {
                    Console.WriteLine("Deleting backend server files");
                    File.Delete(Path.Combine(backendDir, "BansheeBlog.dll")); // Main file first to ensure it is closed
                    DeleteBackendServerFiles(backendDir);

                    Console.WriteLine("Deleting admin frontend files");
                    DeleteAdminFrontendFiles(publicDir);

                    Console.WriteLine("Installing updated backend server files");
                    MoveBackendServerFiles(updateDir, backendDir);

                    Console.WriteLine("Installing updated admin frontend files");
                    MoveAdminFrontendFiles(updateDir, publicDir);

                    Console.WriteLine("Cleaning up after update");
                    Cleanup(updateDir);

                    if (wait)
                    {
                        Console.WriteLine("Starting BansheeBlog");
                        StartServer(backendDir);
                    }

                    Console.WriteLine("\nDone! This updater closes in 3 seconds, bye :)");
                    await Task.Delay(3000);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Blast!");
                    Console.WriteLine(e.Message);
                }
            }
        }