feat: add blue diamond documentation and 'clear' command to pk;config

This commit is contained in:
spiral
2022-02-11 12:25:56 -05:00
parent d0e9ad7193
commit 6a4033b2a9
2 changed files with 17 additions and 8 deletions

View File

@@ -90,17 +90,23 @@ public static class ContextArgumentsExt
public static async Task<bool> MatchClear(this Context ctx, string toClear = null)
{
var matched = ctx.Match("clear", "reset") || ctx.MatchFlag("c", "clear");
var matched = ctx.MatchClearInner();
if (matched && toClear != null)
return await ctx.ConfirmClear(toClear);
return matched;
}
private static bool MatchClearInner(this Context ctx)
=> ctx.Match("clear", "reset", "default") || ctx.MatchFlag("c", "clear");
public static bool MatchRaw(this Context ctx) =>
ctx.Match("r", "raw") || ctx.MatchFlag("r", "raw");
public static bool MatchToggle(this Context ctx)
public static bool MatchToggle(this Context ctx, bool? defaultValue = null)
{
if (defaultValue != null && ctx.MatchClearInner())
return defaultValue.Value;
var yesToggles = new[] { "yes", "on", "enable", "enabled", "true" };
var noToggles = new[] { "no", "off", "disable", "disabled", "false" };