public void GetCommand()
        {
            var input = VInput.GetArgs();

            if (input.Length == 0)
            {
                return;                    //Don't process 0 args
            }
            var commandName = input[0];
            var args        = ArraysUtility.SubArray(input, 1);
            //FIND ALIASES
            var command = CurrentCommands.FirstOrDefault(command => command.Aliases.Any(alias => alias == commandName.ToLower()));

            if (command != null)
            {
                Attempt(command, args);
                return;
            }
            //FIND NAME
            var commandList = StringsUtility.Match(commandName, CurrentCommands);

            if (commandList.Count == 0)
            {
                new GameError($"No commands starting with \"{commandName}\" found!").Write();
            }
            else if (commandList.Count > 1)
            {
                VConsole.WriteLine($"Commands starting with \"{commandName}\":");
                new TextList <Command>(commandList).Write();
            }
            else
            {
                Attempt(commandList[0], args);
            }
        }
示例#2
0
        public override void Execute(Game.Game game)
        {
            var suffix   = SuffixTag.Used ? SuffixArgument.Contents : null;
            var contains = ContainsTag.Used ? ContainsArgument.Contents : null;
            var list     = StringsUtility.Match(NameArgument.IsFilled ? NameArgument.Contents : "", List(game), suffix, contains);

            if (list.Count == 0)
            {
                VConsole.WriteLine($"No {TypeName} found!");
            }
            else if (list.Count > 1)
            {
                var format = new TextListFormat <T>
                {
                    Func = item => item.Name, IsNumbered = NumberedTag.Used, IsGrouped = !SeparatedTag.Used
                };
                new TextList <T>(list, format).Write();
            }
            else
            {
                Describe(list[0]);
            }
        }