Skip to content
emgram769 edited this page Mar 24, 2015 · 7 revisions
     View   --> `Renderer` class, responsible for displaying things.  Either TUI
                 or CLI and provides a `prompt` interface.
 Controller --> `Rice` class, interacts with the user and relays responses to the
                 Model.
     Model  --> `Query`, `Package`, `Installer` classes.  `Query` finds
                `Package`s, `Package`s are used to create `Installer`s and
                `Installer`s install the rice. Each of them is agnostic to the
                 other. This means the `Package` class doesn't know or care if
                 the rice is already installed.  The `Installer` class handles
                 downloading and installing the package given a URL, and never 
                 tries to search for a package via any means.

A typical flow would be:

A user runs rice.py -S i3 bestrice. First a global Rice object is created to facilitate communication between the program and the display. Because arguments are passed a CLI Renderer is created inside Rice. Rice then creates a Query that gets a single match for program i3 theme name bestrice.

Turns out there is no match for i3 bestrice so Query.get_results returns multiple potential results with similar names. With the results from Query (Packages), Rice prompts the user (Renderer.prompt) and determines the user would like to install the 3rd Package.

With this information an Installer is made from the 3rd Package. Installer.download is called and the Installer returns False, indicating that there are already files in the specified download directory. This causes Rice to prompt the user again, asking to overwrite the files in the directory. The user says yes and Installer.download(force=True) is called. Rice prompts the user for a final time, asking if the files to be removed on installation should be backed up. The user responds yes and provides a backup name. Installer.install(backup=backup) is called and the program terminates.

In the case of errors being thrown in any of the Model classes, Rice will handle them and alert the user (via Renderer.prompt).

Clone this wiki locally