refactor(miniooni): divide et impera (#912)
This diff splits miniooni's implementation in smaller and more easily tractable blocks ahead of future refactoring. I'm trying to make `miniooni oonirun -i URL` as possible as `miniooni -i URL oonirun`, because users typically expect this kind of flexibity from modern Unix commands. Part of https://github.com/ooni/probe/issues/2184
This commit is contained in:
parent
196ac55493
commit
7daa686c68
9 changed files with 351 additions and 247 deletions
32
internal/cmd/miniooni/runx.go
Normal file
32
internal/cmd/miniooni/runx.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
//
|
||||
// Run eXperiment by name
|
||||
//
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/oonirun"
|
||||
"github.com/ooni/probe-cli/v3/internal/runtimex"
|
||||
)
|
||||
|
||||
// runx runs the given experiment by name
|
||||
func runx(ctx context.Context, sess oonirun.Session, experimentName string,
|
||||
annotations map[string]string, extraOptions map[string]any, currentOptions Options) {
|
||||
desc := &oonirun.Experiment{
|
||||
Annotations: annotations,
|
||||
ExtraOptions: extraOptions,
|
||||
Inputs: currentOptions.Inputs,
|
||||
InputFilePaths: currentOptions.InputFilePaths,
|
||||
MaxRuntime: currentOptions.MaxRuntime,
|
||||
Name: experimentName,
|
||||
NoCollector: currentOptions.NoCollector,
|
||||
NoJSON: currentOptions.NoJSON,
|
||||
Random: currentOptions.Random,
|
||||
ReportFile: currentOptions.ReportFile,
|
||||
Session: sess,
|
||||
}
|
||||
err := desc.Run(ctx)
|
||||
runtimex.PanicOnError(err, "cannot run experiment")
|
||||
}
|
||||
Loading…
Reference in a new issue