-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCommandServiceConfiguration.cs
More file actions
131 lines (116 loc) · 5.07 KB
/
CommandServiceConfiguration.cs
File metadata and controls
131 lines (116 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using System;
using System.Collections.Generic;
using Ultz.Extensions.Commands.Cooldown;
using Ultz.Extensions.Commands.Parsing.ArgumentParsers;
namespace Ultz.Extensions.Commands
{
/// <summary>
/// Represents a configuration to use with the <see cref="CommandService" />.
/// </summary>
public sealed class CommandServiceConfiguration
{
private RunMode _defaultRunMode = RunMode.Sequential;
private string _separator = " ";
private SeparatorRequirement _separatorRequirement = SeparatorRequirement.Separator;
private StringComparison _stringComparison = StringComparison.OrdinalIgnoreCase;
/// <summary>
/// Gets or sets the <see cref="System.StringComparison" /> used for finding <see cref="Command" />s and
/// <see cref="Module" />s,
/// used by the default <see langword="enum" /> parsers, and comparing <see cref="NullableNouns" />. Defaults to
/// <see cref="StringComparison.OrdinalIgnoreCase" />.
/// </summary>
public StringComparison StringComparison
{
get => _stringComparison;
set
{
if (!Enum.IsDefined(typeof(StringComparison), value))
{
throw new ArgumentOutOfRangeException(nameof(value), "Invalid string comparison.");
}
_stringComparison = value;
}
}
/// <summary>
/// Gets or sets the <see cref="RunMode" /> which determines whether the commands should
/// run sequentially or in parallel. Defaults to <see cref="RunMode.Sequential" />.
/// </summary>
public RunMode DefaultRunMode
{
get => _defaultRunMode;
set
{
if (!Enum.IsDefined(typeof(RunMode), value))
{
throw new ArgumentOutOfRangeException(nameof(value), "Invalid run mode.");
}
_defaultRunMode = value;
}
}
/// <summary>
/// Gets or sets the <see cref="bool" /> which determines whether the extra arguments
/// provided should be ignored. Defaults to <see langword="false" />.
/// </summary>
public bool IgnoresExtraArguments { get; set; }
/// <summary>
/// Gets or sets the <see cref="string" /> separator to use between groups and commands.
/// Defaults to a single whitespace character.
/// </summary>
public string Separator
{
get => _separator;
set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value), "The separator must not be null.");
}
_separator = value;
}
}
/// <summary>
/// Gets or sets the <see cref="Commands.SeparatorRequirement" /> for group and command pathing.
/// Defaults to <see cref="Commands.SeparatorRequirement.Separator" />.
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">
/// <see langword="value" /> must be a valid <see cref="Commands.SeparatorRequirement" /> value.
/// </exception>
public SeparatorRequirement SeparatorRequirement
{
get => _separatorRequirement;
set
{
if (!Enum.IsDefined(typeof(SeparatorRequirement), value))
{
throw new ArgumentOutOfRangeException(nameof(value), "Invalid separator requirement.");
}
_separatorRequirement = value;
}
}
/// <summary>
/// Gets or sets the default argument parser.
/// If <see langword="null" />, will default to <see cref="DefaultArgumentParser.Instance" />.
/// </summary>
public IArgumentParser DefaultArgumentParser { get; set; }
/// <summary>
/// Gets or sets the generator <see langword="delegate" /> to use for <see cref="Cooldown" /> bucket keys.
/// Defaults to <see langword="null" />.
/// </summary>
public CooldownBucketKeyGeneratorDelegate CooldownBucketKeyGenerator { get; set; }
/// <summary>
/// Gets or sets the quotation mark map.
/// If <see langword="null" />, will default to <see cref="CommandUtilities.DefaultQuotationMarkMap" />.
/// </summary>
public IReadOnlyDictionary<char, char> QuoteMap { get; set; }
/// <summary>
/// Gets or sets the collection of nouns to use for <see cref="Nullable{T}" /> parsing.
/// If <see langword="null" />, will default to <see cref="CommandUtilities.DefaultNullableNouns" />.
/// </summary>
public IEnumerable<string> NullableNouns { get; set; }
/// <summary>
/// Gets the default <see cref="CommandServiceConfiguration" />.
/// The equivalent of using <see langword="new" /> <see cref="CommandServiceConfiguration()" />.
/// </summary>
public static CommandServiceConfiguration Default => new CommandServiceConfiguration();
}
}