GlobalFishingWatch / gpsdio

AIS I/O with Python, dictionaries, and the GPSd AIVDM schema.
Other
6 stars 3 forks source link

Support driver options in command line #71

Closed redhog closed 9 years ago

coveralls commented 9 years ago

Coverage Status

Coverage decreased (-0.07%) to 89.35% when pulling cccc29c79ba8a0cef340c6b9ff0b5cf8fb3834ca on driver-options into 86616c75028c35a0e00a1d271d4d5a6897c3079f on master.

geowurster commented 9 years ago

@redhog I made str2type to handle this exact situation. It's more user friendly than asking the user to define all the options as a JSON dict and it still decodes JSON values, although it requires the user to type --i-drv-opt for every option.

Instead of:

@click.option(
    '--i-drv-opts', metavar='OPTIONS', default='{}',
    help='Specify options for the input driver. JSON format.',
)

You would do:

import str2type.ext

@click.option(
    '--i-drv-opt', metavar='NAME=VAL', callback=str2type.ext.click_cb_key_val, multiple=True,
    help='Specify options for the input driver.  Value types are auto-detected, including JSON.',
)

Which always at least gives you an empty dict.