AntelopeIO / DUNES

Docker Utilities for Node Execution
Other
26 stars 17 forks source link

Proposal to improve the CLI parser of DUNE #129

Closed jolly-fellow closed 1 year ago

jolly-fellow commented 1 year ago

The CLI parser, as it implemented now, has following problems:

  1. Arguments of the command line are declared incorrect. It is the cause why the parser can't recognize type of the arguments (optional, required, single/repeating) and can't generate the help description of the CLI syntax in normal Backus–Naur form notation which is the standard for CLI syntax description. Help strings which describe the CLI arguments shouldn't have descriptions like "(Optional)" because the argument must be declared as an optional for the parser. In this case the parser will recognize it correctly and we will not need to parse the optional arguments manually and describe them as optional manually, the parser should do it's work itself. And in this case the parser will generate correct help syntax description where optional arguments will be described in [ ] required arguments in < >, enumerations as 1|2|3 and so on following the BNF notation.
  2. Several CLI options declared as those which have infinite number of arguments but it seems it is incorrect declaration because in the DUNE code they can process only one set of arguments. For example --create-account, --system-newaccount, --bootstrap-system-full, --send-action, --get-table. We should clarify this issue, and if the option takes one set of arguments it could be declared correctly, if the option takes multiple sets of arguments it make sense to take these sets from stdin or a file instead of super long command line which is practically impossible to edit manually.
  3. IMHO it make sense to group the options by commands as it made in antler-proj. In this case we will have syntax like:
    dune [global args] <command> [<command specific args>]

    global arguments are those which accepted with any command like --debug, --help and so on. For each command will be created a dedicated subparser object, command line syntax will be much easier because it will be limited by one command and it allows to have command specific arguments with the same names but different behavior depending on the command.

  4. IMHO it make sense to decrease length of the options because it is difficult to type so long names, or at least make a short version of each long option.

Thus for the beginning I propose to start from clarification of chapter 2. It allows to fix a bug #123 and then discuss about solving of other problems at proper time.

jolly-fellow commented 1 year ago

It was agreed with @larryk85 to have the only set of the options for commands described in 2. I will update declaration of these options and check if they work correctly. It fix the bug #123

jolly-fellow commented 1 year ago

The described problems were partially solved in the fix of #123 . I have made a small research about solving of the parser problems by rewriting it with subparsers and found that this approach doesn't help to solve the problems. Read the results of the research here: https://github.com/AntelopeIO/DUNE/wiki/Result-of-small-research-about-the-DUNE-CLI-parser

Therefore this proposal will not work and should be closed.

jolly-fellow commented 1 year ago

Closed because of the proposed approach doesn't solve the described problems.