Maybe there was an answer to one of the similar questions, but I couldn't find it.
What I need.
I have a table to read from: table with most recent data (fast), table with data for one day (day).
I want to read from day-table by default and from fast-table if I provide an argument -f in the command line.
Then I have defaults for each argument. So if I don't provide any arguments ("-s" or "-f"), I want to use "day" with the default value. If I use something like "-s 20161001" or "-f 1452557323", I want to use that value. If use "-f", I want to use "-f" default value.
All I have right now is:
table_choice = parser.add_mutually_exclusive_group(required=True)
table_choice.add_argument(
'-s', '--day-table',
dest='day',
help='day table data',
default="path/" + day(),
)
table_choice.add_argument(
'-f', '--fast-table',
dest='fast',
help='fast table data',
default=fast(),
)
But sadly it doesn't work like I want. "script -f" returns:
Script: error: argument -f/--fast-table: expected one argument
Only works if I have provided a value.