cmd/cue/cmd: undo panic when multiple commands are run in one process
This should resolve the panics encountered by cmd/cue/cmd Go API users
who were running multiple commands in a single Go process,
which is a fairly reasonable use case which worked before.
This mostly reverts https://cuelang.org/cl/1198496, but it adds a note
for future reference to the relevant code and updates the new test.
I briefly considered alternative routes such as only doing the mkRunE
setup work on the first command run. However, it's not clear to me
that such a strategy would lead to better behavior for those users.
For example, if they rely on the collection of CUE stats,
it would be very odd if only the first command run were to produce them.
Fixes #3458.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Iadb274de8c3d233796ee6feb33e40ffc03bc0f08
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202646
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>