

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Retrieval Augmented Generation
incomplete
2: What Is Search?
incomplete
3: Project Overview
incomplete
4: Keyword Search
incomplete
5: Text Processing
incomplete
6: Punctuation
incomplete
7: Tokenization
incomplete
8: Stop Words
incomplete
9: Stemming
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
We'll implement Webflyx as a collection of command line scripts that perform search operations on a local dataset of movies.
import argparse
def main() -> None:
parser = argparse.ArgumentParser(description="Keyword Search CLI")
subparsers = parser.add_subparsers(dest="command", help="Available commands")
search_parser = subparsers.add_parser("search", help="Search movies using keywords")
search_parser.add_argument("query", type=str, help="Search query")
args = parser.parse_args()
match args.command:
case "search":
# print the search query here
pass
case _:
parser.print_help()
if __name__ == "__main__":
main()
This is just some boilerplate that uses the argparse library to parse command line arguments.
uv run cli/keyword_search_cli.py search "your search query" will execute the "search" case and populate "your search query" into the args.query variable.uv run cli/keyword_search_cli.py with no (or invalid) arguments will print the parser's help message.Notice that main is annotated with -> None because this CLI entrypoint doesn't return a value.
Searching for: QUERY
Where QUERY is the value of args.query.
Run and submit the CLI tests.