Bookbot is done! Almost...
You've probably noticed that most CLI tools you're used to (ls, cd, git, etc.) aren't limited to a single "hard coded" input. Right now bookbot can only analyze books/frankenstein.txt. That's not very useful, is it? Let's update the program so that we can pass it a path to our book instead of using a hardcoded value.
The built in sys module provides access to command line arguments. In particular sys.argv is a list of strings representing the arguments passed to the script. The first argument is the script name, the rest are the arguments.
For example, python3 main.py will result in a sys.argv list that looks like this:
print(sys.argv)
# Prints ['main.py']
And python3 main.py books/frankenstein.txt will result in a sys.argv list that looks like this:
print(sys.argv)
# Prints ['main.py', 'books/frankenstein.txt']
print(sys.argv[0])
# Prints 'main.py'
print(sys.argv[1])
# Prints 'books/frankenstein.txt'
import sys
Use the books that are linked above, or the CLI tests will fail.
You can also run the following command to download and create the files:
wget -O books/mobydick.txt https://storage.googleapis.com/qvault-webapp-dynamic-assets/course_assets/mobydick.txt
wget -O books/prideandprejudice.txt https://storage.googleapis.com/qvault-webapp-dynamic-assets/course_assets/prideandprejudice.txt
Run and submit the CLI tests.