示例#1
0
 /// <summary>
 ///     Sets the <see cref="CommandBuilder.Name"/> in the command builder.
 /// </summary>
 /// <param name="builder">Source builder.</param>
 /// <param name="name">Name of the command. It cannot be <see langword="null"/>, empty or contain whitespace after removing the prefix. Root commands can have null names.</param>
 /// <returns><paramref name="builder"/>, to allow chaining.</returns>
 /// <exception cref="ArgumentException">The name of the command is <see langword="null"/>, empty or contains whitespace after removing the prefix.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null"/>.</exception>
 public static CommandBuilder SetName(this CommandBuilder builder, string name)
 {
     (builder ?? throw Exceptions.BuildArgumentNull(nameof(builder)))
     .Name = (builder.IsRoot && name is null) || Validations.IsValidCommandName(name) ? name : throw Exceptions.BuildArgumentInvalidCommandName(nameof(name));
     return(builder);
 }
示例#2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="CommandBuilder"/> class that builds a non-root command.
 /// </summary>
 /// <param name="name">The name of the command. It cannot be <see langword="null"/>, empty or contain whitespace after removing the prefix.</param>
 /// <exception cref="ArgumentException"><paramref name="name"/> is <see langword="null"/>, empty or contains whitespace after removing the prefix.</exception>
 public CommandBuilder(string name)
 {
     this.name   = Validations.IsValidCommandName(name) ? name : throw Exceptions.BuildArgumentInvalidCommandName(nameof(name));
     this.IsRoot = false;
 }