p-ranav/argparse

In usage message, it feels strange to have a required argument in "Optional arguments" section

nmoreaud opened this issue · 0 comments

Currently, argparse distinguishes "positional arguments" and "optional arguments".
I wonder if "optional arguments" should be splitted into 2 separate categories: "named arguments" and "optional arguments", so that required arguments are listed first.
Or rename "Optional arguments" into "Named arguments", because it feels weird to have a required argument in "Optional arguments" section.

Also, positional arguments are listed first, but in "Usage: " line, input is the last parameter

Usage: main [--help] [--verbose] --configuration VAR [--optional1 VAR] [--optional2 VAR] [--optional3 VAR] input

A description

Positional arguments:
  input                      json input file [required]

Optional arguments:
  -h, --help                 shows help message and exits 
  -v, --verbose              verbose output 
  -c, --configuration        propagation model configuration [required]
  --optional1              optional argument 1
  --optional2              optional argument 2
  --optional3              optional argument 3

vs

Usage: main [--help] [--verbose] --configuration VAR [--optional1 VAR] [--optional2 VAR] [--optional3 VAR] input

A description

Positional arguments:
  input                      json input file [required]

Named arguments:
  -c, --configuration        propagation model configuration [required]

Optional arguments:
  -h, --help                 shows help message and exits 
  -v, --verbose              verbose output 
  --optional1              optional argument 1
  --optional2              optional argument 2
  --optional3              optional argument 3