From d351fb2ffebbb7665945ebe5a77d8211ae2b0cc4 Mon Sep 17 00:00:00 2001 From: openhands Date: Sat, 5 Sep 2026 21:53:46 +0000 Subject: [PATCH] Add H for help in keyboard mode Co-authored-by: openhands --- README.md | 4 ++-- src/Minesweeper.Cli/CommandParser.cs | 1 + src/Minesweeper.Cli/GameSession.cs | 2 +- src/Minesweeper.Cli/Program.cs | 2 +- tests/Minesweeper.Core.Tests/CommandParserTests.cs | 4 ++++ 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2f47d57..7df70ff 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,8 @@ Rows are numbered `1..N` down the left, columns are lettered `A..Z` (then `AA..` | `help` / `?` | list the commands | | `quit` / `q` | leave | -In `--keys` mode: arrows move, `Enter`/`Space` reveals, `F` flags, `C` chords, `1`/`2`/`3` change -difficulty, `N` starts a new board, `Q` or `Esc` quits. +In `--keys` mode: arrows move, `Enter`/`Space` reveals, `F` flags, `C` chords, `H` shows help, +`1`/`2`/`3` change difficulty, `N` starts a new board, `Q` or `Esc` quits. Colours are on when writing to a terminal and off when the output is redirected; set `NO_COLOR` to force them off. The process exits `0` after a win, `1` otherwise. diff --git a/src/Minesweeper.Cli/CommandParser.cs b/src/Minesweeper.Cli/CommandParser.cs index bfdc0bc..08e819f 100644 --- a/src/Minesweeper.Cli/CommandParser.cs +++ b/src/Minesweeper.Cli/CommandParser.cs @@ -54,6 +54,7 @@ public static class CommandParser ConsoleKey.F => new Command.FlagAtCursor(), ConsoleKey.C => new Command.ChordAtCursor(), ConsoleKey.N => new Command.NewGame(), + ConsoleKey.H => new Command.ShowHelp(), ConsoleKey.D1 => new Command.ChangeDifficulty(GameDifficulty.Beginner), ConsoleKey.D2 => new Command.ChangeDifficulty(GameDifficulty.Intermediate), ConsoleKey.D3 => new Command.ChangeDifficulty(GameDifficulty.Expert), diff --git a/src/Minesweeper.Cli/GameSession.cs b/src/Minesweeper.Cli/GameSession.cs index 94eb648..d3a25fd 100644 --- a/src/Minesweeper.Cli/GameSession.cs +++ b/src/Minesweeper.Cli/GameSession.cs @@ -92,7 +92,7 @@ public sealed class GameSession quit | q leave Rows are numbered 1..N down the left, columns are lettered A..Z across the top. - With --keys, use the arrow keys to move, Enter/Space to reveal, F to flag, C to chord. + With --keys, use the arrow keys to move, Enter/Space to reveal, F to flag, C to chord, H for help. """; private static MinesweeperGame NewGame(GameDifficulty difficulty, int? seed) => diff --git a/src/Minesweeper.Cli/Program.cs b/src/Minesweeper.Cli/Program.cs index 05f81a6..625208d 100644 --- a/src/Minesweeper.Cli/Program.cs +++ b/src/Minesweeper.Cli/Program.cs @@ -87,7 +87,7 @@ public static class Program } else if (keys) { - Console.WriteLine(palette.Dim("arrows move · enter reveal · f flag · c chord · 1/2/3 difficulty · n new · q quit")); + Console.WriteLine(palette.Dim("arrows move · enter reveal · f flag · c chord · 1/2/3 difficulty · n new · h help · q quit")); } else { diff --git a/tests/Minesweeper.Core.Tests/CommandParserTests.cs b/tests/Minesweeper.Core.Tests/CommandParserTests.cs index 7bb5bcc..4f35b1a 100644 --- a/tests/Minesweeper.Core.Tests/CommandParserTests.cs +++ b/tests/Minesweeper.Core.Tests/CommandParserTests.cs @@ -178,6 +178,10 @@ public class CommandParserTests Assert.IsType(CommandParser.FromKey(Key(ConsoleKey.Q, 'q'))); } + [Fact] + public void FromKey_Help() => + Assert.IsType(CommandParser.FromKey(Key(ConsoleKey.H, 'h'))); + [Fact] public void FromKey_UnmappedKey_IsANoOp() => Assert.IsType(CommandParser.FromKey(Key(ConsoleKey.B, 'b')));