feat(miniooni): make CLI much more user friendly (#913)

Part of https://github.com/ooni/probe/issues/2184, because I wanted
to allow swapping commands and options more freely.

As a side effect, this PR closes https://github.com/ooni/probe/issues/2248.

AFAICT, every usage that was legal before is still legal. What has
changed seems the freedom to swap commands and options and a much
better help that lists the available options.
This commit is contained in:
Simone Basso 2022-08-31 12:44:46 +02:00 committed by GitHub
commit 0bc6aae601
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 265 additions and 124 deletions

View file

@ -208,6 +208,8 @@ func CanonicalizeExperimentName(name string) string {
name = "dnscheck"
case "stun_reachability":
name = "stunreachability"
case "web_connectivity@v_0_5":
name = "web_connectivity@v0.5"
default:
}
return name
@ -216,7 +218,7 @@ func CanonicalizeExperimentName(name string) string {
// NewFactory creates a new Factory instance.
func NewFactory(name string) (*Factory, error) {
name = CanonicalizeExperimentName(name)
factory := allexperiments[name]
factory := AllExperiments[name]
if factory == nil {
return nil, fmt.Errorf("no such experiment: %s", name)
}