Skip to content

MrEhbr/go-fsm

go-fsm

CI License GitHub release codecov Made by Alexey Burmistrov

go-fsm is a command line tool that generates finite state machine for Go struct.

Usage

FSM generation

Usage: go-fsm gen -p ./examples/transitions -s Order -f State -o order_fsm.go -t ./examples/transitions/transitions.json
   --package, -p      package where struct is located (default: default is current dir(.))
   --struct, -s       struct name
   --field, -f        state field of struct
   --output, -o       output file name (default: default srcdir/<struct>_fsm.go)
   --transitions, -t  path to file with transitions
   --noGenerate, -g   don't put //go:generate instruction to the generated code (default: false)
   --graph-output, -a value  path to transition graph file in dot format

This will generate finite state machine for struct Order with transitions defined in ./examples/transitions/transitions.json file. Transition graph will be generated from transitions file and output will be in dot format

Action generation

Usage: go-fsm actions gen --tpl examples/transitions/action.go.tpl -o examples/transitions/actions -t examples/transitions/transitions.json
   --template value, --tpl value  template for action
   --output_dir value, -o value   output dir
   --transitions value, -t value  path to file with transitions

This will generate actions stubs from ./examples/transitions/action.go.tpl file.

Action doc generation

Usage: go-fsm actions doc -o examples/transitions/actions/README.md -t examples/transitions/transitions.json
   --output value, -o value       output file name
   --transitions value, -t value  path to file with transitions

This will generate actions doc README.md from transitions file. Further runs of the command will add only new actions and update the Transitions where action appears section.

Install

Using go

go get -u github.com/MrEhbr/go-fsm/cmd/go-fsm

Download releases

https://github.com/MrEhbr/go-fsm/releases

License

© 2020 [Alexey Burmistrov]

Licensed under the Apache License, Version 2.0 (LICENSE). See the COPYRIGHT file for more details.

SPDX-License-Identifier: Apache-2.0

About

command line tool that generates finite state machine for Go struct

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published