From 185f1165cfab14a85fdeb82a9c078165e73482e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 11 Jul 2018 10:17:19 +0200 Subject: [PATCH] Update FSM documentation --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 503967a..9a8e647 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ There are two ways to define a state machine: - Using a YAML configuration file - Implementing it in Python by hand -The first option enables you to handle FSM callbacks and custom logic in any programming language (not just Python) and is generally really easy to work with. +The first option allows you to handle FSM callbacks and custom logic in any programming language (not just Python) and is generally really easy to work with (you can execute arbitrary shell commands on events). You should choose this method unless you have good reason not to. This involves creating your YAML file (see `test_fsm.yml` for an example) and parsing it using our `YamlFSM` class (see `event_handler_main.py` for an example). @@ -224,6 +224,12 @@ Transition callbacks: - `before` - `after` +In your YAML file you can use these in the state and transition objects as keys, then add a shell command to run as a value (again, see `test_fsm.yml` for examples). + +It is also possible to add preconditions to transitions. +This is done by adding a `predicates` key with a list of shell commands to run. +If you do this, the transition will only succeed if the return code of all predicates was `0` (as per unix convention for success). + ## Baby steps When creating your own challenge the process should be the following: