refactor cmd: thin main, testable run(io.Writer), AllStrategies in engine
The strategy list moves into the engine (AllStrategies), where the API and frontend will read it too: one source of truth, per the handoff. main shrinks to the standard Go shell pattern: all work happens in run(out io.Writer) error; main only maps the error to stderr and the exit code. Writing to an interface instead of stdout is what lets main_test.go capture output in a bytes.Buffer. errcheck flagged every unchecked Fprintf, so formatting became pure Sprintf string building with one checked write at the end: nicer than discarding four errors with '_, _ ='.
This commit is contained in:
parent
e73db0bdd4
commit
2a5b78cb9a
3 changed files with 63 additions and 20 deletions
|
|
@ -11,6 +11,12 @@ const (
|
|||
StrategyMostConnected Strategy = "most-connected"
|
||||
)
|
||||
|
||||
// AllStrategies lists every strategy in display order. The CLI, and later
|
||||
// the API and frontend, read this one list; nothing redefines it.
|
||||
func AllStrategies() []Strategy {
|
||||
return []Strategy{StrategyNone, StrategyRandom, StrategyMostConnected}
|
||||
}
|
||||
|
||||
// Config fully describes one simulation world. It is the single source of
|
||||
// truth for parameters: API and frontend types will be generated from the
|
||||
// structs in this file, never redefined by hand. Identical configs produce
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue