         if error
             cb( error )
 
-if options.help
+device_address = ->
+    if !options['device']
+        console.log "device address (--device) reqired!"
+        process.exit 1
+
+    options['device']
+
+print_usage = ->
     console.log "usage: ble_flash [options] <input-file>"
     console.log "options:"
     console.log "  --help, -h                   this help"

    console.log "  --device <mac>, -d <mac>     48 bit MAC address of the device to be flashed"
    console.log "  --version, -v                request version string from device"
    console.log "  --list, -l                   scan for a list of bootloaders"
    process.exit 0

if options.list

                                    peripheral.disconnect()
                                    stop_waiting()

else if options.version
    scan_devices device_address(), (device)->
        if device
            connect_device device, (peripheral, error)->
                if error
                    console.log "#{device.address}: Error: #{error}"
                    process.exit 1
                else
                    execute OPC_GET_VERSION, (error, version)->
                        if error
                            console.log "error requesting version string: #{error}"
                            process.exit 1
                        else
                            console.log version
                            process.exit 0
        else
            console.log "device not found!"
            process.exit 1

else
    console.log "Unrecognized command."
    print_usage()
    process.exit 1

# if options.version
#     connect ->
