From 417227e590dc66aafb105b2c61ed3d3eaedcf4ca Mon Sep 17 00:00:00 2001 From: Will Fuqua Date: Sun, 14 Jun 2026 21:51:31 +0700 Subject: [PATCH] Improve help text on keybindings --- CSharpRepl.Services/Configuration.cs | 9 +++++---- CSharpRepl/Commands/CommandLine.cs | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CSharpRepl.Services/Configuration.cs b/CSharpRepl.Services/Configuration.cs index c583640..1eb39c4 100644 --- a/CSharpRepl.Services/Configuration.cs +++ b/CSharpRepl.Services/Configuration.cs @@ -31,6 +31,9 @@ public sealed class Configuration public const string PromptDefault = "> "; + public const string KeyBindingPatternDescription = + "Key pattern is a key with optional modifiers (Alt/Shift/Control) e.g. 'Enter', 'Control+A'"; + public static readonly string ApplicationDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".csharprepl"); @@ -212,8 +215,6 @@ internal static KeyPressPattern ParseKeyPressPattern(string keyPattern) { if (string.IsNullOrEmpty(keyPattern)) return default; - const string GeneralInfo = "Key pattern must contain one key with optional modifiers (Alt/Shift/Control). E.g. 'Enter', 'Control+A', '(', 'Alt+.', ..."; - ConsoleKey? key = null; char? keyChar = null; ConsoleModifiers modifiers = default; @@ -235,7 +236,7 @@ internal static KeyPressPattern ParseKeyPressPattern(string keyPattern) } else { - throw new ArgumentException($"Unable to parse '{part}'. {GeneralInfo}", nameof(keyPattern)); + throw new ArgumentException($"Unable to parse '{part}'. {KeyBindingPatternDescription}", nameof(keyPattern)); } } @@ -252,7 +253,7 @@ internal static KeyPressPattern ParseKeyPressPattern(string keyPattern) return new KeyPressPattern(keyChar.Value); } - static void Throw() => throw new ArgumentException(GeneralInfo, nameof(keyPattern)); + static void Throw() => throw new ArgumentException(KeyBindingPatternDescription, nameof(keyPattern)); static bool TryParseConsoleModifiers(string text, out ConsoleModifiers result) { diff --git a/CSharpRepl/Commands/CommandLine.cs b/CSharpRepl/Commands/CommandLine.cs index a5f7307..43ea68b 100644 --- a/CSharpRepl/Commands/CommandLine.cs +++ b/CSharpRepl/Commands/CommandLine.cs @@ -630,7 +630,8 @@ private static string GetHelp(string configFilePath) $" [green]--tabSize[/] [cyan][/]: {TabSize.Description}" + NewLine + $" [green]--culture[/] [cyan][/]: {Culture.Description}" + NewLine + NewLine + - $" Key Bindings" + NewLine + + $" Key Bindings: {Configuration.KeyBindingPatternDescription}" + NewLine + + $" Specifying an option multiple times makes any of its key bindings trigger the action." + NewLine + $" [green]--triggerCompletionListKeys[/] [cyan][/]: {TriggerCompletionListKeyBindings.Description}" + NewLine + $" [green]--newLineKeys[/] [cyan][/]: {NewLineKeyBindings.Description}" + NewLine + $" [green]--submitPromptKeys[/] [cyan][/]: {SubmitPromptKeyBindings.Description}" + NewLine +