Beispiel #1
0
        internal static async Task Start(GlobalOptions options)
        {
            if (options is null)
            {
                Helper.WriteLine("Invalid arguments");
                await GlobalOptions.Parse(new[] { "--help" }).ConfigureAwait(false);

                Helper.needExit = true;
                Helper.Exit(ErrorCode.InvalidArguments);
            }

            Helper.needVerbose = options.Verbose;
            Helper.WriteVerbose("Verbose activated", ConsoleColor.Magenta);
            Helper.WriteVerbose($"Work mode: {options.Mode}", ConsoleColor.Yellow);
            Helper.needExit = options.Exit;
            Helper.WriteVerbose($"Need exit: {options.Exit}", ConsoleColor.Yellow);
            Helper.WriteVerbose($"Working directory: {(!(options.Path is null) ? options.Path.FullName : "null")}", ConsoleColor.Yellow);
            Helper.WriteVerbose($"Working directory exist: {options.Path?.Exists.ToString() ?? "null"}", ConsoleColor.Yellow);
            if (!(options.Path is null) && options.Path.Exists)
            {
                Helper.WriteVerbose($"Setting working directory: {options.Path.FullName}", ConsoleColor.Yellow);
                Directory.SetCurrentDirectory(options.Path.FullName);
            }

            switch (options.Mode)
            {
            case WorkMode.Patcher:
                await Patcher.Start(options).ConfigureAwait(false);

                break;

            case WorkMode.Publicizer:
                await Publicizer.Start(options).ConfigureAwait(false);

                break;

            default:
                Helper.WriteLine("Invalid work mode given", ConsoleColor.Red);
                Helper.Exit(ErrorCode.InvalidMode);
                break;
            }

            // Thus we allow the waiting
            Helper.Exit(ErrorCode.None);
        }
Beispiel #2
0
 public static async Task Parse(GlobalOptions goptions, string[] args)
 {
     RootCommand.Handler = CommandHandler.Create <ModeOptions>(options => Publicizer.Main(goptions, options));
     await RootCommand.InvokeAsync(args).ConfigureAwait(false);
 }