protected TargetUserCommand(
     LocaleCommand command,
     LocaleArgument argument,
     params ICommandArgument[] arguments
     ) : base(command, argument, arguments)
 {
 }
Exemplo n.º 2
0
        protected Command([NotNull] LocaleCommand localization, [CanBeNull] params ICommandArgument[] arguments)
        {
            Localization = localization;

            var argumentList = new List <ICommandArgument>(
                (arguments ?? new ICommandArgument[0]).Where(argument => argument != null)
                );

            UnsortedArguments = argumentList.ToImmutableList() ?? throw new InvalidOperationException();

            argumentList.Sort(
                (a, b) =>
            {
                if (a == null)
                {
                    return(1);
                }

                if (b == null)
                {
                    return(-1);
                }

                if (a.IsRequiredByDefault && !b.IsRequiredByDefault)
                {
                    return(-1);
                }

                if (!a.IsRequiredByDefault && b.IsRequiredByDefault)
                {
                    return(1);
                }

                if (a.IsPositional)
                {
                    return(b.IsPositional ? 0 : -1);
                }

                return(b.IsPositional ? 1 : 0);
            }
                );

            Arguments = argumentList.ToImmutableList() ?? throw new InvalidOperationException();

            NamedArguments =
                argumentList.Where(
                    argument => !argument?.IsPositional ??
                    throw new InvalidOperationException(@"No null arguments should be in the list.")
                    )
                .ToImmutableList() ??
                throw new InvalidOperationException();

            PositionalArguments =
                argumentList.Where(
                    argument => argument?.IsPositional ??
                    throw new InvalidOperationException(@"No null arguments should be in the list.")
                    )
                .ToImmutableList() ??
                throw new InvalidOperationException();
        }
 protected TargettedCommand(
     [NotNull] LocaleCommand command,
     [NotNull] LocaleArgument argument,
     [NotNull] params ICommandArgument[] arguments
     ) : base(command, arguments.Prepend(new VariableArgument <string>(argument, RequiredIfNotHelp, true)))
 {
 }
 protected TargetClientCommand(
     [NotNull] LocaleCommand command,
     [NotNull] LocaleArgument argument,
     [NotNull] params ICommandArgument[] arguments
     ) : base(command, argument, arguments)
 {
 }
Exemplo n.º 5
0
 protected ModeratorActionCommand(
     [NotNull] LocaleCommand command,
     [NotNull] LocaleArgument target,
     [NotNull] LocaleArgument duration,
     [NotNull] LocaleArgument ip,
     [NotNull] LocaleArgument reason
     ) : base(
         command, target, new VariableArgument <int>(duration, RequiredIfNotHelp, true),
         new VariableArgument <bool>(ip, RequiredIfNotHelp, true),
         new VariableArgument <string>(reason, RequiredIfNotHelp, true)
         )
 {
 }
 protected ServerCommand(
     LocaleCommand localization,
     params ICommandArgument[] arguments
     ) : base(localization, arguments)
 {
 }
 protected HelpableCommand(LocaleCommand localization, params ICommandArgument[] arguments) :
     base(localization, arguments.Prepend(new HelpArgument()))
 {
 }
Exemplo n.º 8
0
 protected ServerCommand(
     [NotNull] LocaleCommand localization,
     [NotNull] params ICommandArgument[] arguments
     ) : base(localization, arguments)
 {
 }