Enhanced CLI ~ High Level Code Overview - uchicago-cs/chiventure GitHub Wiki
z # CLI Documentation
The documentation for the CLI module of chiventure
Spring 2021 Team: Marta Beramendi-Conde, Beza Desta, Marcus Goodman, David Chen, Sam Donio
Spring 2022 Team: Faruk Badur, Brianna Zeng, Kate Shchukina, Miles Gardner, Matteo Restuccia
The cli (command-line interface) is the way in which the player interacts with the chiventure program. By typing things into the command line the user is able to perform a multitude of actions inside of chiventure. At a high level the cli takes in a string that is inputted by the user, currently parses it with our own library, and then, depending on what the user has inputted, performs different actions.
In Spring 2022 we are working on using the Bison parsing library to actually do the parsing in order to support more complicated commands currently not possible in Chiventure.
cli Module
The cli module consists of several parts
The shell
shell.c and shell.h
- The shell file contains mostly system internal functions that do things like print a list of supported commands, print a greeting when the game starts, prints a history of commands that have been used so far, or prints a message.
The parser
parser.c and parser.h
- The parser files work to parse the input from the user. The way this is currently implemented is by turning the users input into a linked list of 'tokens' and then passing this linked list along so that the user's inputs can be performed (if valid). These linked lists can only be up to 4 terms long as of now.
The operations
operations.c and operations.h
- The operations files contain all of the operations that can be used in chiventure, everything from picking up an item to loading a new wdl file. These all work by being passed a list of token strings that are expected to be formatted for the function call.
- To add a new function, this is where it would be implemented.
The command list
cmdlist.c and cmdlist.h
- The cmdlist files serve the purpose of allowing the user to be able to list the commands that they have inputted during any game.
The commands
cmd.c and cmd.h
- The cmd files defines the command datatype, the lookup entry for a hastable, and many functions that relate to interacting with these datatypes.