dlr-eoc / prosEO

prosEO – A Processing System for Earth Observation Data
GNU General Public License v3.0
14 stars 1 forks source link

[prosEO CLI] Different logic calling subcommands > options > parameters ? #24

Closed dlr-tangosierra closed 4 years ago

dlr-tangosierra commented 4 years ago

Testing parameters: User Login: no user login Mission : no mission

Context: With reference to issues 19 and 23, it was observed that there seems to be a different logic between subcommands when calling subcommand + option or subcommand + option + parameter

Example from issue 23: Example output: prosEO> orbit update (E2802) User not logged in (E2853) Spacecraft code and/or orbit number missing prosEO> orbit update abc (E2802) User not logged in (E2853) Spacecraft code and/or orbit number missing prosEO> orbit update abc 10 (E2802) User not logged in (E2803) User null not authorized to manage orbits for mission null

Example from issue 19: prosEO> configuration delete (E2918) Required parameter className not found for command delete prosEO> configuration delete abc (E2918) Required parameter configurationVersion not found for command delete prosEO> configuration delete abc 1 (E2802) User not logged in (E2803) User null not authorized to manage configurations for mission null prosEO>

Difference: When executing orbit update, the system returns the error message "Spacecraft code and/or orbit number missing", realizing at the same time that both the option and the parameter are missing. On the contrary during the execution of configuration delete, the system seems to only focus on the missing option and then exiting.

Questions: While, understandably, both commands require a username and a mission, is this difference in logic expected? The parameters seem mandatory in both cases, so why does the system behave differently?

tangobravo62 commented 4 years ago

The difference in behaviour is intentional, because in the case of the "orbit update" command, the parameters spacecraft code and orbit number are optional (they might be taken from the input file), whereas for "configuration delete" the parameters are mandatory. Therefore in the first case the parser accepts the command and the missing input is only detected during execution of the command, whereas in the second case the parser already detects a syntactically incorrect command.

Note that after fixing the bug that commands could be executed without login, the transcript of the commands above looks like this:

prosEO> orbit update
(E2853) Spacecraft code and/or orbit number missing
prosEO> orbit update abc
(E2853) Spacecraft code and/or orbit number missing
prosEO> orbit update abc 10
(E2854) Orbit number 10 not found for spacecraft abc
prosEO> 
prosEO> configuration delete
(E2918) Required parameter className not found for command delete
prosEO> configuration delete abc
(E2918) Required parameter configurationVersion not found for command delete
prosEO> configuration delete abc 1
(E2995) Configuration for processor abc with configuration version 1 not found
prosEO> 

The help text display was updated to show, whether a parameter is optional or mandatory:

prosEO> orbit update -h
Update a set of orbits for the given spacecraft
Options:
    -f, --file        Path to file to read the orbit definitions from
        --format      The file format (one of { JSON, XML, YAML }; default value JSON)
    -h, --help        Show help information for the current command level (top level commands, when called from the shell command line)
Positional parameters:
    spacecraftCode    (optional) The code of the spacecraft the orbits belong to (mandatory if not read from file)
    orbitNumber       (optional) The number of the orbit to update (mandatory if not read from file)
    attribute         (optional) An orbit attribute to update in the form "<attribute name>=<attribute value>", only allowed if no orbit file is given (i. e. a single orbit is updated)
Subcommands:
    -- none --
prosEO> configuration delete -h
Remove a configuration from the current mission and processor class
Options:
    -h, --help        Show help information for the current command level (top level commands, when called from the shell command line)
Positional parameters:
    className         (mandatory) The name of the processor class
    configurationVersion  (mandatory) The version of the configuration to delete
Subcommands:
    -- none --

@dlr-tangosierra : Explanation acceptable?

dlr-tangosierra commented 4 years ago

The explanation seems ok and the addition of the mandatory/optional information is helpful. I am closing the issue.