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:
@@ -1,11 +1,11 @@
|
||||
package registry
|
||||
|
||||
// Where we register all the available experiments.
|
||||
var allexperiments = map[string]*Factory{}
|
||||
var AllExperiments = map[string]*Factory{}
|
||||
|
||||
// ExperimentNames returns the name of all experiments
|
||||
func ExperimentNames() (names []string) {
|
||||
for key := range allexperiments {
|
||||
for key := range AllExperiments {
|
||||
names = append(names, key)
|
||||
}
|
||||
return
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["dash"] = &Factory{
|
||||
AllExperiments["dash"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return dash.NewExperimentMeasurer(
|
||||
*config.(*dash.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["dnscheck"] = &Factory{
|
||||
AllExperiments["dnscheck"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return dnscheck.NewExperimentMeasurer(
|
||||
*config.(*dnscheck.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["dnsping"] = &Factory{
|
||||
AllExperiments["dnsping"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return dnsping.NewExperimentMeasurer(
|
||||
*config.(*dnsping.Config),
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["example"] = &Factory{
|
||||
AllExperiments["example"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return example.NewExperimentMeasurer(
|
||||
*config.(*example.Config), "example",
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["facebook_messenger"] = &Factory{
|
||||
AllExperiments["facebook_messenger"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return fbmessenger.NewExperimentMeasurer(
|
||||
*config.(*fbmessenger.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["http_header_field_manipulation"] = &Factory{
|
||||
AllExperiments["http_header_field_manipulation"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return hhfm.NewExperimentMeasurer(
|
||||
*config.(*hhfm.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["http_invalid_request_line"] = &Factory{
|
||||
AllExperiments["http_invalid_request_line"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return hirl.NewExperimentMeasurer(
|
||||
*config.(*hirl.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["http_host_header"] = &Factory{
|
||||
AllExperiments["http_host_header"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return httphostheader.NewExperimentMeasurer(
|
||||
*config.(*httphostheader.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["ndt"] = &Factory{
|
||||
AllExperiments["ndt"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return ndt7.NewExperimentMeasurer(
|
||||
*config.(*ndt7.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["psiphon"] = &Factory{
|
||||
AllExperiments["psiphon"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return psiphon.NewExperimentMeasurer(
|
||||
*config.(*psiphon.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["quicping"] = &Factory{
|
||||
AllExperiments["quicping"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return quicping.NewExperimentMeasurer(
|
||||
*config.(*quicping.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["riseupvpn"] = &Factory{
|
||||
AllExperiments["riseupvpn"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return riseupvpn.NewExperimentMeasurer(
|
||||
*config.(*riseupvpn.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["run"] = &Factory{
|
||||
AllExperiments["run"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return run.NewExperimentMeasurer(
|
||||
*config.(*run.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["signal"] = &Factory{
|
||||
AllExperiments["signal"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return signal.NewExperimentMeasurer(
|
||||
*config.(*signal.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["simplequicping"] = &Factory{
|
||||
AllExperiments["simplequicping"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return simplequicping.NewExperimentMeasurer(
|
||||
*config.(*simplequicping.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["sni_blocking"] = &Factory{
|
||||
AllExperiments["sni_blocking"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return sniblocking.NewExperimentMeasurer(
|
||||
*config.(*sniblocking.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["stunreachability"] = &Factory{
|
||||
AllExperiments["stunreachability"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return stunreachability.NewExperimentMeasurer(
|
||||
*config.(*stunreachability.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["tcpping"] = &Factory{
|
||||
AllExperiments["tcpping"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return tcpping.NewExperimentMeasurer(
|
||||
*config.(*tcpping.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["telegram"] = &Factory{
|
||||
AllExperiments["telegram"] = &Factory{
|
||||
build: func(config any) model.ExperimentMeasurer {
|
||||
return telegram.NewExperimentMeasurer(
|
||||
config.(telegram.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["tlsping"] = &Factory{
|
||||
AllExperiments["tlsping"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return tlsping.NewExperimentMeasurer(
|
||||
*config.(*tlsping.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["tlstool"] = &Factory{
|
||||
AllExperiments["tlstool"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return tlstool.NewExperimentMeasurer(
|
||||
*config.(*tlstool.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["tor"] = &Factory{
|
||||
AllExperiments["tor"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return tor.NewExperimentMeasurer(
|
||||
*config.(*tor.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["torsf"] = &Factory{
|
||||
AllExperiments["torsf"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return torsf.NewExperimentMeasurer(
|
||||
*config.(*torsf.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["urlgetter"] = &Factory{
|
||||
AllExperiments["urlgetter"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return urlgetter.NewExperimentMeasurer(
|
||||
*config.(*urlgetter.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["vanilla_tor"] = &Factory{
|
||||
AllExperiments["vanilla_tor"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return vanillator.NewExperimentMeasurer(
|
||||
*config.(*vanillator.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["web_connectivity"] = &Factory{
|
||||
AllExperiments["web_connectivity"] = &Factory{
|
||||
build: func(config any) model.ExperimentMeasurer {
|
||||
return webconnectivity.NewExperimentMeasurer(
|
||||
config.(webconnectivity.Config),
|
||||
|
||||
@@ -12,9 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Note: the name inserted into the table is the canonicalized experiment
|
||||
// name though we advertise using `web_connectivity@v0.5`.
|
||||
allexperiments["web_connectivity@v_0_5"] = &Factory{
|
||||
AllExperiments["web_connectivity@v0.5"] = &Factory{
|
||||
build: func(config any) model.ExperimentMeasurer {
|
||||
return webconnectivity.NewExperimentMeasurer(
|
||||
config.(*webconnectivity.Config),
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
allexperiments["whatsapp"] = &Factory{
|
||||
AllExperiments["whatsapp"] = &Factory{
|
||||
build: func(config interface{}) model.ExperimentMeasurer {
|
||||
return whatsapp.NewExperimentMeasurer(
|
||||
*config.(*whatsapp.Config),
|
||||
|
||||
Reference in New Issue
Block a user