private static async Task Main()

in CommandLine/GlobalStorage/Program.cs [27:109]


        private static async Task<int> Main(string[] args)
        {
            int exitCode = 0;
            string invokedVerb = string.Empty;
            BaseOptions baseOptions = null;
            try
            {
                // Only assign the option and verb here, as the commandlineParser doesn't support async callback yet.
                var result = Parser.Default.ParseArguments<QuotaOptions, BlobMetadataOptions, DeleteOptions, DownloadOptions, UploadOptions>(args)
                    .WithParsed(options =>
                    {
                        var verbAttribute =
                            Attribute.GetCustomAttribute(options.GetType(), typeof(VerbAttribute)) as VerbAttribute;
                        invokedVerb = verbAttribute?.Name;
                        baseOptions = options as BaseOptions;
                    })
                    .WithNotParsed(err => exitCode = -1);

                DevAccount account = ToolAuthentication.LoadLastSignedInUser();
                if (account == null)
                {
                    Console.Error.WriteLine("Didn't found dev sign in info, please use \"XblDevAccount.exe signin\" to initiate.");
                    return -1;
                }

                Console.WriteLine($"Using Dev account {account.Name} from {account.AccountSource}");

                if (invokedVerb == "quota" && baseOptions is QuotaOptions quotaOptions)
                {
                    exitCode = await OnGetQuota(quotaOptions);
                }
                else if (invokedVerb == "list" && baseOptions is BlobMetadataOptions blobMetadataOptions)
                {
                    exitCode = await OnGetBlobMetadata(blobMetadataOptions);
                }
                else if (invokedVerb == "delete" && baseOptions is DeleteOptions deleteOptions)
                {
                    exitCode = await OnDelete(deleteOptions);
                }
                else if (invokedVerb == "download" && baseOptions is DownloadOptions downloadOptions)
                {
                    exitCode = await OnDownload(downloadOptions);
                }
                else if (invokedVerb == "upload" && baseOptions is UploadOptions uploadOptions)
                {
                    exitCode = await OnUpload(uploadOptions);
                }
                else
                {
                    Console.Error.WriteLine("Parsing parameters error.");
                    exitCode = -1;
                }
            }
            catch (HttpRequestException ex)
            {
                Console.WriteLine($"Error: GlobalStorage {invokedVerb} failed.");

                if (ex.Message.Contains(Convert.ToString((int)HttpStatusCode.Unauthorized)))
                {
                    Console.WriteLine(
                        $"Unable to authorize the account with XboxLive service with scid : {baseOptions?.ServiceConfigurationId} and sandbox : {baseOptions?.Sandbox}, please contact your administrator.");
                }
                else if (ex.Message.Contains(Convert.ToString((int)HttpStatusCode.Forbidden)))
                {
                    Console.WriteLine(
                        "Your account doesn't have access to perform the operation, please contact your administrator.");
                }
                else
                {
                    Console.WriteLine(ex.Message);
                }

                return -1;
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Error: unexpected error found.");
                Console.Error.WriteLine(ex.Message);
                exitCode = -1;
            }

            return exitCode;
        }