zonemaster / zonemaster-backend

The Zonemaster Backend - part of the Zonemaster project
Other
14 stars 23 forks source link

Redesign the CLI interface of zmb #708

Open mattias-p opened 3 years ago

mattias-p commented 3 years ago

The current design of the command line parameters of zmb is not great. Some effort has been made to strike a balance between 1) flexibility in generating invalid requests and 2) convenience in generating valid requests, but the resulting interface leaves a lot to be desired.

Requirements:

mattias-p commented 1 year ago

Design proposal

The central idea behind this proposal is to make zmb able to make any JSON request remove any specific knowledge from zmb about the particulars of the RPCAPI.

zmb [OPTION ...] METHOD [NAME=VALUE ...]
zmb --paramstype=omitted [OPTION ...] METHOD

OPTION
  One of:
    --help
    --verbose
    --server URL
        The server to query.
        Accepts a URL. Default: "http://localhost:5000/".
    --paramstype PARAMSTYPE
        The JSON value type to use for the JSON-RPC request "method" member.
        Accepts either "object" or "omitted". Default: "object".

METHOD
  Used as a string argument for the "method" member of the JSON-RPC request.
  Accepts any string.

NAME
  The name in a name/value pair in the JSON-RPC request "params" object.
  Accepts any string that contains neither `"` nor `=`.
  All names in a given call must be unique.

VALUE
  The value in a name/value pair in the JSON-RPC request "params" object.
  Accepts any JSON value.

Here are valid commands for calling job_create with domain arguments of each JSON value type. (The resulting JSON-RPC calls are not necessarily valid though, but that's the point.)

zmb job_create domain=null
zmb job_create domain=false
zmb job_create domain=true
zmb job_create domain=1
zmb job_create domain='[1,2]'
zmb job_create domain='{"foo":true}'
zmb job_create domain='"zonemaster.net"'

The following command should print a validation error and terminate without making an RPCAPI call. Because "zonemaster.net" is valid JSON but zonemaster.net isn't.

zmb job_create domain=zonemaster.net

Possible extensions and variations

matsduf commented 1 year ago

The normal test should be simple to run. The special test, e.g. null domain, could be more complicated. We need zmb for Zonemaster. What you suggest is another tool.

Instead of changing zmb, create a new tool within or outside Zonemaster-Backend. Then both tools could be available.

I prefer zmb as-is.

mattias-p commented 1 year ago

Can't you use zmtest to start a test?

matsduf commented 1 year ago

Can't you use zmtest to start a test?

I could, but there are other operations to do, e.g. start a batch or fetch a result of previous test, that zmtest does not support.

mattias-p commented 1 year ago

Sure we can repurpose zmb to be a use-case-level tool and add a separate protocol-level tool.

matsduf commented 1 year ago

That sounds fine.