As an optional argument in my Python 3.8 app, I would like to offer a convenient conversion from date+time to GPS week + time-of-week that exits after printing the converted result.
parser.add_argument('-c', '--convert-date-time-to-gps', nargs=7, type=lambda d: datetime.strptime(d, '%y %m %d %H %M %S %f'), \
help=f'use "YY[YY] M[M] D[D] h[h] m[m] s[s] ms" as date time format to be converted to gps date, e.g. "{datetime.now().strftime("%Y %m %d %H %M %S %f")}"')
# GPSTime conversion follows here..
As you can see in the help argument, the user should be able to enter either "2021 08 13 23 08 00 42" but also
"21 8 13 23 8 0 42" as comandline input.
What would be the most convenient way to reach this? Especially, to avoid the ugly usage message like
usage: main [-h] [-m {run,test,debug}] [-g] [-v]
[-c CONVERT_DATE_TIME_TO_GPS CONVERT_DATE_TIME_TO_GPS CONVERT_DATE_TIME_TO_GPS CONVERT_DATE_TIME_TO_GPS CONVERT_DATE_TIME_TO_GPS CONVERT_DATE_TIME_TO_GPS CONVERT_DATE_TIME_TO_GPS]
[project_config]
with the CONVERT_DATE_TIME_TO_GPS item repeated 7 times?
metavaris used to change the help display.