Пример #1
0
        private static CommandLineParameters GetCommandline(string[] args)
        {
            CommandLineParameters commandLineParameters = CommandLineParameters.FromFile(args);

            if (commandLineParameters == null)
            {
                commandLineParameters = CommandLineParameters.FromArguments(args);
            }

            // Checks
            if (commandLineParameters.Result.HasErrors)
            {
                ErrorHandler.Log($"Error in parameters: {commandLineParameters.Result.ErrorText}");
            }

            commandLineParameters.FileForVersion = Path.GetFullPath(commandLineParameters.FileForVersion);
            if (!File.Exists(commandLineParameters.FileForVersion))
            {
                ErrorHandler.Log($"File not exists: {commandLineParameters.FileForVersion}");
            }

            var extension = Path.GetExtension(commandLineParameters.FileForVersion)?.ToLower();

            if (extension != ".dll" &&
                extension != ".exe")
            {
                ErrorHandler.Log($"File type not supported: {extension}");
            }

            if (commandLineParameters.ReleaseAttachments != null)
            {
                for (var index = 0; index < commandLineParameters.ReleaseAttachments.Count; index++)
                {
                    commandLineParameters.ReleaseAttachments[index] =
                        Path.GetFullPath(commandLineParameters.ReleaseAttachments[index]);
                    var attachment = commandLineParameters.ReleaseAttachments[index];
                    if (!File.Exists(attachment))
                    {
                        ErrorHandler.Log($"Attachment file not found: {attachment}");
                    }
                }
            }

            LogParameter(nameof(commandLineParameters.GitHubRepo), commandLineParameters.GitHubRepo);
            LogParameter(nameof(commandLineParameters.GitHubToken), commandLineParameters.GitHubToken);
            LogParameter(nameof(commandLineParameters.FileForVersion), commandLineParameters.FileForVersion);
            LogParameter(nameof(commandLineParameters.IsChangelogFileCreationEnabled),
                         commandLineParameters.IsChangelogFileCreationEnabled);
            LogParameter(nameof(commandLineParameters.IsPreRelease), commandLineParameters.IsPreRelease);
            LogParameter(nameof(commandLineParameters.IsUpdateOnly), commandLineParameters.IsUpdateOnly);
            LogParameter(nameof(commandLineParameters.IssueFilterLabel), commandLineParameters.IssueFilterLabel);
            LogParameter(nameof(commandLineParameters.IssueLabels), commandLineParameters.IssueLabels);
            LogParameter(nameof(commandLineParameters.ReleaseAttachments), commandLineParameters.ReleaseAttachments);

            return(commandLineParameters);
        }