Пример #1
0
 public override bool Fill(string input)
 {
     try
     {
         Content = int.Parse(input);
         IsNull  = false;
         return(true);
     }
     catch (FormatException)
     {
         WriteError(Name + Text(" needs an integer argument. (Received ")
                    + Text(input).Apply(VTextTransform.Quote()).Apply(VTextTransform.SetForeground(ColorStandards.Input))
                    + Text(")"));
         return(false);
     }
 }
Пример #2
0
        public override bool Fill(string input)
        {
            if (input.ToLower().StartsWith("f"))
            {
                Content = false;
                IsNull  = false;
            }
            else if (input.ToLower().StartsWith("t"))
            {
                Content = true;
                IsNull  = false;
            }
            else
            {
                WriteError(Name + Text(" needs a boolean argument. (Received ")
                           + Text(input).Apply(VTextTransform.Quote()).Apply(VTextTransform.SetForeground(ColorStandards.Input))
                           + Text(")"));
                IsNull = true;
            }

            return(!IsNull);
        }
Пример #3
0
        private static void DisplayCommand(Game game, Command command)
        {
            game.AddElement(new TitleElement(command));
            WriteLine(command.Description.Apply(VTextTransform.Capitalize()));
            var usage = Text("Usage: ") + command;

            foreach (var argument in command.Arguments)
            {
                usage += Text(" ") + argument.Apply(VTextTransform.Quote("[", "]"))
                         .Apply(VTextTransform.SetForeground(ColorStandards.Argument));
            }

            foreach (var argument in command.OptionalArguments)
            {
                usage += Text(" ") + argument.Apply(VTextTransform.Quote("(", ")"))
                         .Apply(VTextTransform.SetForeground(ColorStandards.Optional));
            }

            WriteLine(usage);
            if (command.Arguments.Count > 0 || command.OptionalArguments.Count > 0)
            {
                WriteLine(Text("Arguments:", ColorStandards.Title));
            }

            foreach (var argument in command.Arguments)
            {
                WriteLine(Text(" ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Argument)) + Text(": ") + argument.Description);
            }
            foreach (var argument in command.OptionalArguments)
            {
                WriteLine(Text(" ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Optional)) + Text(": ") + argument.Description);
            }

            if (command.Tags.Count > 0)
            {
                WriteLine(Text("Tags:", ColorStandards.Title));
            }

            foreach (var tag in command.Tags)
            {
                VText tagUsage = Text(" ") + tag;
                foreach (var argument in tag.Arguments)
                {
                    tagUsage += Text(" ") + argument.Apply(VTextTransform.Quote("[", "]"))
                                .Apply(VTextTransform.SetForeground(ColorStandards.Argument));
                }

                foreach (var argument in tag.OptionalArguments)
                {
                    tagUsage += Text(" ") + argument.Apply(VTextTransform.Quote("(", ")"))
                                .Apply(VTextTransform.SetForeground(ColorStandards.Argument));
                }

                WriteLine(tagUsage);
                WriteLine(Text("  ") + tag.Description);

                foreach (var argument in tag.Arguments)
                {
                    WriteLine(Text("  ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Argument)) + Text(": ") + argument.Description);
                }
                foreach (var argument in tag.OptionalArguments)
                {
                    WriteLine(Text("  ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Optional)) + Text(": ") + argument.Description);
                }
            }
        }