Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make --verify-ssl choices explicit #289

Merged
merged 1 commit into from Jul 8, 2019
Merged

Conversation

mfussenegger
Copy link
Member

This adds true/false as explicit choices so that the help output is a
bit friendlier.

[--verify-ssl {True,False}]
--verify-ssl {True,False}
      Enable or disable the verification of the server SSL
      certificate

In CLIs with boolean flags it is also sometimes the case that you've a
--no-* variant or that you can use no or something like that. So
having to pass false is not necessarily intuitive.

@mfussenegger mfussenegger requested a review from chaudum July 5, 2019 13:56
Copy link
Contributor

@chaudum chaudum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --verify-ssl argument already supports yes/true/t/1/no/false/f/0 as input, but I agree, adding the choices makes the help text friendlier.

@mfussenegger
Copy link
Member Author

Ah right, should we list all choices then? Or maybe go with ('true', 'false', 'yes', 'no') ?

@mfussenegger
Copy link
Member Author

@chaudum pushed a fixup so that the error message is also friendlier if an invalid value is used:

crash --verify-ssl foobar
usage: crash [-h] [-v] [-A] [-a] [-U USERNAME] [-W] [--schema SCHEMA]
             [--history FILENAME] [--config FILENAME]
             [-c STATEMENT | --sysinfo] [--hosts [HOSTS [HOSTS ...]]]
             [--verify-ssl {true,false,yes,no}] [--cert-file FILENAME]
             [--key-file FILENAME] [--ca-cert-file FILENAME] [--format FORMAT]
             [--version]
crash: error: argument --verify-ssl: Input `foobar` cannot be converted to a boolean, expected one of: [yes, true, t, 1, no, false, f, 0]

@chaudum
Copy link
Contributor

chaudum commented Jul 5, 2019

@chaudum pushed a fixup so that the error message is also friendlier if an invalid value is used:

crash --verify-ssl foobar
usage: crash [-h] [-v] [-A] [-a] [-U USERNAME] [-W] [--schema SCHEMA]
             [--history FILENAME] [--config FILENAME]
             [-c STATEMENT | --sysinfo] [--hosts [HOSTS [HOSTS ...]]]
             [--verify-ssl {true,false,yes,no}] [--cert-file FILENAME]
             [--key-file FILENAME] [--ca-cert-file FILENAME] [--format FORMAT]
             [--version]
crash: error: argument --verify-ssl: Input `foobar` cannot be converted to a boolean, expected one of: [yes, true, t, 1, no, false, f, 0]

Afaik the choices must the possible return values of the type function:

$ crash --verify-ssl true
usage: crash [-h] [-v] [-A] [-a] [-U USERNAME] [-W] [--schema SCHEMA]
             [--history FILENAME] [--config FILENAME]
             [-c STATEMENT | --sysinfo] [--hosts [HOSTS [HOSTS ...]]]
             [--verify-ssl {true,false,yes,no}] [--cert-file FILENAME]
             [--key-file FILENAME] [--ca-cert-file FILENAME] [--format FORMAT]
             [--version]
crash: error: argument --verify-ssl: invalid choice: True (choose from 'true', 'false', 'yes', 'no')

This adds true/false as explicit choices so that the help output is a
bit friendlier.

    [--verify-ssl {true, false, yes, no}]
    --verify-ssl {true, false, yes, no}
          Enable or disable the verification of the server SSL
          certificate

In CLIs with boolean flags it is also sometimes the case that you've a
``--no-*`` variant or that you can use ``no`` or something like that. So
having to pass ``false`` is not necessarily intuitive.
@mfussenegger mfussenegger merged commit 42bca85 into master Jul 8, 2019
@mfussenegger mfussenegger deleted the j/verify-ssl-choices branch July 8, 2019 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants