#!/usr/bin/env python

USAGE = """Show airport status

"""

from systematic.shell import Script
from darwinist.airport import AirportStatus

script = Script(USAGE)
script.add_argument('-d', '--details', action='store_true', help="Show AP details")
script.add_argument('-s', '--signal-strength', action='store_true', help="Show signal strength of nearby APs")
args = script.parse_args()

status = AirportStatus()
status.probe()

if args.signal_strength:
    script.message('SSID: {0}'.format(status['SSID']))
    for ap in status.proximity():
        script.message('BSSID: %(BSSID)s RSSI: %(RSSI)s dB' % ap)

elif args.details:
    for k in sorted(status.keys()):
        script.message('{0:20} {1}'.format(k, status[k]))

else:
    script.message(status)
