def StartCli(args, adb_commands, extra=None, **device_kwargs):
    """Starts a common CLI interface for this usb path and protocol."""
    try:
        dev = adb_commands()
        dev.ConnectDevice(port_path=args.port_path, serial=args.serial, default_timeout_ms=args.timeout_ms,
                          **device_kwargs)
    except usb_exceptions.DeviceNotFoundError as e:
        print('No device found: {}'.format(e), file=sys.stderr)
        return 1
    except usb_exceptions.CommonUsbError as e:
        print('Could not connect to device: {}'.format(e), file=sys.stderr)
        return 1
    try:
        return _RunMethod(dev, args, extra or {})
    except Exception as e:  # pylint: disable=broad-except
        sys.stdout.write(str(e))
        return 1
    finally:
        dev.Close()
Starts a common CLI interface for this usb path and protocol.
adb/common_cli.py