azriel91 / peace

Zero Stress Automation
https://peace.mk
Apache License 2.0
110 stars 1 forks source link

Consolidate `*Cmd` logic #120

Closed azriel91 closed 1 year ago

azriel91 commented 1 year ago

Currently:

What we would like for all commands:

Use cases:

azriel91 commented 1 year ago

Design / implementation issue:

  1. ApplyCmd wants to call StatesDiscoverCmd::current
  2. Inlining the state current discovery logic into ApplyCmd, and executing concurrently requires an intemediate outcomes rx, which is essentially re-implementing CmdBase.
  3. Current logic of StatesDiscoverCmd takes in &mut CmdCtx.
  4. For automation logic, StatesDiscoverCmd needs immutable references to the flow and parameter specs.
  5. However, CmdCtx and SingleProfileSingleFlowView contain &mut Output, and &mut CmdProgressTracker.
  6. This makes it hard to pass the container of flow / parameter information around.
  7. Only the top level command needs &mut Output and &mut CmdProgressTracker to set up progress rendering.
  8. We could move those two out of the view and into the CmdCtx, so that fn_exec can take in the *View and progress and outcome Senders, and this view can be passed to sub commands.
  9. If we don't do that, then every command needs to pass through about 5 separate parameters.

So, we should split Output and CmdProgressTracker out of the view into ScopeViewAndOutput.