Code question: making a command that executes other commands

Faraday
Tue, 17 Jul 2018 22:05:14 +0000

In general I would avoid trying to “trigger” other commands (to use a Penn/Tiny term) and look instead to leveraging or creating shared helper methods.

For example… lots of different commands can result in creating a job like what you’re describing. They don’t do it by triggering the request command, they do so by calling a shared helper:

 Jobs.create_job(category, title, description, author)

Same for poses - all of the various say/pose/emit commands leverage a pair of helpers (the first to translate things like :waves into Faraday waves, the second to actually emit):

 message = PoseFormatter.format(enactor_name, pose)
 Scenes.emit(enactor, message)

Stringing together helper methods is more efficient and cleaner than trying to directly execute other commands.