viash-io / viash

script + metadata = standalone component
https://viash.io
GNU General Public License v3.0
39 stars 2 forks source link

Enhancement: Proposal of new --help format. #56

Closed BlackDragonBE closed 3 years ago

BlackDragonBE commented 3 years ago

Here's my proposal of a new --help format:

Current format:

<component description>

Options:
    <name>=<type>
        type: <type>, <attributes>, default: <default_value>
        attributes: <is_required>, <multiple_allowed>, ...
        <description>

Proposed format:

<component name>
    <component description>
    usage: <component usage example>

Options:
    <name>
        usage: <example>
        type: <type>
        default: <default_value>
        attributes: <is_required>, <multiple_allowed>, <output>, <must_exist>, ...
        <description>

With this proposal the following changes would be made:

rcannood commented 3 years ago

I deviated a little bit from the proposed format to reduce the size of the text generated:

Example:

$ viash run src/test/resources/testbash/config.vsh.yaml -p src/test/resources/testbash/platform_custom.yaml -- -h
testbash 0.1
Prints out the parameter values.
Checking what happens with multiline descriptions.

Options:
    input
        type: file, required parameter, file must exist
        example: input.txt
        An input file with positional arguments.
        More checks for multiline descriptions.
        Testing some characters that should be escaped: ` $ \

    --real_number
        type: double, required parameter
        A real number with positional arguments.

    --whole_number
        type: integer, required parameter
        A whole number with a standard flag.

    -s
        type: string, required parameter
        A sentence or word with a short flag.

    --truth
        type: boolean_true
        A switch flag.

    --falsehood
        type: boolean_false
        A switch flag which is false when specified.

    --reality
        type: boolean
        A switch flag without predetermined state.

    -o, --output
        type: file, output
        Write the parameters to a json file.

    --log
        type: file, output
        An optional log file.

    --optional
        type: string
        An optional string.

    --optional_with_default
        type: string
        default: The default value.

    --multiple
        type: string, multiple values allowed

    multiple_pos
        type: string, multiple values allowed

@BlackDragonBE Is this okay for you?

BlackDragonBE commented 3 years ago

@rcannood Looks excellent! It's more compact than what I suggested, and that's a good thing. 👍