UCL-ARC / shortlister

0 stars 0 forks source link

Decouple description of keypress action from function #49

Closed tamuri closed 5 hours ago

tamuri commented 3 days ago

Currently, the description of the keypress is inferred from the called function's docstring. This means that when functions are used for several different keystrokes, they get the same description. It also prohibits a function's docstring being descriptive and the keypress's description (as shown to the user) being short and succint.

We can decouple this by putting the description of the keypress in the options dictionary with the function to call in a tuple. For example:

        self.options_applicant_detail = {
            "n": (self.switch_next_applicant, "next"),
            "p": (self.switch_prev_applicant, "previous"),
            "e": (self.edit_score_start, "score"),
            "N": (self.create_applicant_note, "add note")
etc...
        }

We can also add description when building options dynamically:

self.options = {
            str(i): (self.edit_score_confirm, s)
            for i, s in enumerate(self.current_criterion.scores)
        }

and so on.

The handling of the keypress and print help when pressing '?' will need to be updated to either get the function to execute (index=0 of the value) or get the help/description (index=1 of the value)