Exercise: Improve the color selector
There are several parts of this exercise:
- The color selector created previously shows menu items numbered from 0. Change it so the displayed numbers will start at 1 but that it will still work correctly.
- Currently the user can give any value on the command line. Incluing "nonsense". Check that the given value is indeed one of the possible values hard-coded in the script. Report an error and quit if it isn't.
- Allow the user to supply a flag called --force If this flag is present allow any value as a color. Even "nonsense".
- Read the names of the valid colors from the colors.txt file.
- Allow the user to supply a --file flag as in "--file mycolor.txt" and take the name of the file with the colors from there.
Published on 2015-10-23
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.
Comment on this post