public void PrintResources(string name, TextWriter writer, int outputMaxWidth)
        {
            var requestForAll     = string.IsNullOrWhiteSpace(name);
            var userSpecifiedName = !requestForAll && !name.Contains('*');
            var matches           = requestForAll ? _retriever.Get() : _retriever.Get(name);

            if (userSpecifiedName)
            {
                switch (matches.Count)
                {
                case 0:
                    throw new ConfigurationException($"No resources found with name: {name}");

                case 1:
                    _printer.Print(writer, matches.Single(), outputMaxWidth);
                    break;

                default:
                    _printer.Print(writer, matches, outputMaxWidth);
                    break;
                }
            }
            else
            {
                _printer.Print(writer, matches, outputMaxWidth);
            }
        }
Exemple #2
0
        private LocalReplay ValidateReplay(string replay, uint turn)
        {
            if (string.IsNullOrWhiteSpace(replay))
            {
                throw new ConfigurationException("No replay provided for the Gif being created");
            }
            if (turn == default)
            {
                throw new ConfigurationException("No turn provided for the Gif being created");
            }

            var replays = _replayRetriever.Get(replay);

            switch (replays.Count)
            {
            case 0:
                throw new ConfigurationException($"No replays found with name: {replay}");

            case > 1:
                throw new ConfigurationException($"More than one replay found matching pattern: {replay}");
            }

            var foundReplay = replays.Single();

            if (foundReplay.Details.Turns.Count < turn)
            {
                throw new ConfigurationException($"Replay {replay} does not have a turn {turn}");
            }

            return(foundReplay);
        }
Exemple #3
0
        private T GetResource(string name)
        {
            var resourcesFound = _retriever.Get(name);

            if (resourcesFound.Count == 0)
            {
                throw new ConfigurationException($"No resource found with name: {name}");
            }

            if (resourcesFound.Count > 1)
            {
                throw new ConfigurationException($"More than one resource found with name matching: {name}");
            }

            return(resourcesFound.Single());
        }
        public async Task <int> OnExecuteAsync()
        {
            var pattern = string.Empty;

            if (Name != "*" && !string.IsNullOrEmpty(Name))
            {
                pattern = Name;
            }

            foreach (var replayPath in _replayRetriever.Get(pattern))
            {
                Logger.Information($"Processing: {replayPath.Paths.WAgamePath}");
                await _replayLogGenerator.GenerateReplayLog(replayPath.Paths.WAgamePath);
            }

            return(0);
        }