def handle_cli_id(apiclient, given_instance_id=None):
    """Infer instance ID given command-line interface arguments

    Note that if given_instance_id is not None, then this function
    returns it and takes no other action. Eventually this function
    might be changed to validate the given ID, e.g., check that it
    exists and that given API token is sufficient to use it.
    """
    if given_instance_id is not None:
        return given_instance_id
    active_instances = apiclient.get_instances()
    if len(active_instances) == 1:
        return active_instances[0]
    if len(active_instances) > 1:
        print('ambiguous command because more than one active instance')
    else: # len(active_instances) == 0:
        print('no active instances')
    return None