Open merlinz01 opened 2 weeks ago
Nope, the real way to do it is with good ol' Python itself. Way more flexible, support for it everywhere, type checking, docstrings, etc.
Something like this:
state = State(
"test",
[
State(
"Foo the bar",
command.Run("cat foo | bar --stdin"),
onchange=service.Restart('blah'),
),
State(
"Foo the baz",
command.Run("cat foo | baz "),
cond=Or(Cmd("test -f /nonexistent"), sys.platform == "linux"),
),
...
]
)
if __name__ == '__main__':
state.run()
This will also make it easy to implement goodies like having "defer" states that only run once if triggered at least once.
The current state syntax works well, but has these drawbacks:
type
,if
, andonchange
are parallel with operation arguments. Which brings backward-compatibility concerns.Better: