private static void RemoveFeed(FeedConfigurationOptions options, CodeGenerationConfiguration configuration)
        {
            var feedName = options.Name?.Trim();

            if (string.IsNullOrEmpty(feedName))
            {
                Console.WriteLine("No feed name provided");
                Environment.ExitCode |= (int)ExitCodes.InvalidFeedName;
            }
            else
            {
                var feedItem = configuration.NugetFeeds.FirstOrDefault(x =>
                                                                       x.Name.Equals(feedName, StringComparison.InvariantCultureIgnoreCase));

                if (feedItem == null)
                {
                    Console.WriteLine($"No feed with name {feedName} found");
                    Environment.ExitCode |= (int)ExitCodes.InvalidFeedName;
                }
                else
                {
                    configuration.NugetFeeds.Remove(feedItem);
                    UpdateConfiguration(configuration);

                    Console.WriteLine($"Nuget feed {feedName} removed");
                }
            }
        }
        public static void Execute(FeedConfigurationOptions options)
        {
            var configuration = LoadConfiguration();

            switch (options.Command)
            {
            case FeedConfigurationOptions.Commands.Show:
                ShowFeeds(options, configuration);
                break;

            case FeedConfigurationOptions.Commands.Add:
                AddFeed(options, configuration);
                break;

            case FeedConfigurationOptions.Commands.Remove:
                RemoveFeed(options, configuration);
                break;
            }
        }
        private static void AddFeed(FeedConfigurationOptions options, CodeGenerationConfiguration configuration)
        {
            var feedName = options.Name?.Trim();

            if (string.IsNullOrEmpty(feedName))
            {
                Console.WriteLine("No feed name provided");
                Environment.ExitCode |= (int)ExitCodes.InvalidFeedName;
                return;
            }

            var source = options.Source?.Trim();

            if (string.IsNullOrEmpty(source))
            {
                Console.WriteLine("No feed source provided");
                Environment.ExitCode |= (int)ExitCodes.InvalidFeedSource;
                return;
            }

            var feedItemExists = configuration.NugetFeeds.Any(x =>
                                                              x.Name.Equals(feedName, StringComparison.InvariantCultureIgnoreCase));

            if (feedItemExists)
            {
                Console.WriteLine($"Feed with name {feedName} already exists");
                Environment.ExitCode |= (int)ExitCodes.InvalidFeedName;
            }
            else
            {
                var feedItem = new NugetSourceConfiguration
                {
                    Name            = feedName,
                    Source          = source,
                    ProtocolVersion = options.ProtocolVersion
                };

                configuration.NugetFeeds.Add(feedItem);
                UpdateConfiguration(configuration);

                Console.WriteLine($"Nuget feed {feedName} added");
            }
        }
        private static void ShowFeeds(FeedConfigurationOptions options, CodeGenerationConfiguration configuration)
        {
            if (configuration.NugetFeeds == null || !configuration.NugetFeeds.Any())
            {
                Console.WriteLine("<not set>");
            }
            else
            {
                var maxNameLength = configuration
                                    .NugetFeeds
                                    .Select(f => f.Name.Length)
                                    .Max();

                Console.WriteLine($"{"Name",-24} Source");
                foreach (var feed in configuration.NugetFeeds)
                {
                    var protocolVersionSuffix = feed.ProtocolVersion > 0 ? $" (protocol {feed.ProtocolVersion})" : "";
                    Console.WriteLine($"{feed.Name,-24} {feed.Source}{protocolVersionSuffix}");
                }
            }
        }