Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --help, --version, error on invalid CLI arguments #64

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

sohang3112
Copy link
Contributor

@sohang3112 sohang3112 commented Jan 27, 2025

Show help message (all supported arguments):

$ 2048 --help           # alternatively: 2048 -h
Usage: 2048 [OPTION]
Play the game 2048 in the console

Options:
  --help       Show this help message.
  --version    Show version number.
  bluered      Use a blue-to-red color scheme (requires 256-color terminal support). If unsupported, it will fall back to black-to-white.
  blackwhite   The default color scheme is black-to-white (requires 256-color terminal support).
  test         Run the test suite.

Show version:

$ 2048 --version      # alternatively: 2048 -v
2048.c version 1.0

Handle invalid CLI arguments:

$ ./2048 some invalid arguments
Invalid number of arguments
Usage: 2048 [OPTION]
Play the game 2048 in the console

Options:
  --help       Show this help message.
  --version    Show version number.
  bluered      Use a blue-to-red color scheme (requires 256-color terminal support). If unsupported, it will fall back to black-to-white.
  blackwhite   The default color scheme is black-to-white (requires 256-color terminal support).
  test         Run the test suite.
$ echo $?
1

Verified that all tests are passing:

$ 2048 test
All 13 tests executed successfully

Fixes Issue #56

@sohang3112 sohang3112 changed the title Add cli options --help, --version Add --help, --version, error on invalid CLI arguments Jan 27, 2025
@mevdschee mevdschee merged commit e47f215 into mevdschee:main Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants