klipspringr / wordle-cli

Play Wordle on the command line.
37 stars 13 forks source link

Using argparse module to parse commandline arguments #5

Open DeepSpace2 opened 2 years ago

DeepSpace2 commented 2 years ago

Hi! nice side project :)

I've created this PR to introduce the usage of the built-in argparse module to handle commandline arguments instead of manually parsing sys.argv.

I also fixed a small bug in the current implementation that allowed the usage of --solution flag to create a game with a non-guessable solution (for example, you could create a game using abcde as a solution, but could never guess it),

klipspringr commented 2 years ago

So, I should definitely have been using argparse from the beginning -- this PR is much nicer than my manual effort! Thank you for the contribution!

However this PR changes the usage from --today|DAY|SOLUTION to --today|--day DAY|--solution SOLUTION. I'm not sure I want to make a user-facing change for coding style reasons. I had a quick look at implementing the existing behaviour in argparse but I'm not sure it would be any cleaner than the existing code.

I have gone ahead and fixed (855b58) the bug you reported re allowing unguessable solutions (thanks!). I think it's fine to allow a fixed solution that is not in the official solutions list -- it just has to be in the guesses list.