miquecg / meteoservice

Web service and client for temperature in cities

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support arguments in the command line

miquecg opened this issue · comments

Some examples:

  • --city # forecasts by city
  • --host # web service configuration
  • --port # web service configuration
  • --days # number of days of the forecast
# Passing args to the script when testing
testargs = ['commandline.py', '--city', 'vigo']
monkeypatch.setattr('sys.argv', testargs)

# Possible implementation
parser.add_argument('--city', required=True, help='blablabla')
parser.add_argument('--host-and-port', nargs=2, metavar=('HOST', 'PORT'),
                    default=['localhost', '8000'],
                    help='Lorem ipsum sit dolor amet')

args = parser.parse_args()
host, port = args.host_and_port