Author rrt
Recipients rrt
Date 2016-11-04.15:19:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1478272763.12.0.609109547521.issue28609@psf.upfronthosting.co.za>
In-reply-to
Content
In Python 3.5.2, with a positional argument with nargs='*', running the program with no arguments gives an error like this:

usage: caffeinate [-h] [-V] COMMAND [ARGUMENT [ARGUMENT ...]]
caffeinate: error: the following arguments are required: COMMAND, ARGUMENT

Here it is clear from the (correct, though redundant) syntax that "ARGUMENT" is optional, but the error message claims, incorrectly, that it is required.

The add_argument calls used were:

parser.add_argument('COMMAND', help='command to run')
parser.add_argument('ARGUMENT', nargs='*', help='arguments to COMMAND')
parser.add_argument('-V', '--version', action='version', version=PROGRAM_NAME + ' ' + VERSION)
History
Date User Action Args
2016-11-04 15:19:23rrtsetrecipients: + rrt
2016-11-04 15:19:23rrtsetmessageid: <1478272763.12.0.609109547521.issue28609@psf.upfronthosting.co.za>
2016-11-04 15:19:23rrtlinkissue28609 messages
2016-11-04 15:19:22rrtcreate