<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def cli(wio):
    '''
    Login with your Wio account.

    \b
    DOES:
        Login and save an access token for interacting with your account on the Wio.

    \b
    USE:
        wio login
    '''
    mserver = wio.config.get("mserver", None)
    if mserver:
        click.echo(click.style('> ', fg='green') + "Current server is: " +
            click.style(mserver, fg='green'))
        if click.confirm(click.style('Would you like login with a different server?', bold=True), default=False):
            choise_server(wio)
    else:
        choise_server(wio)

    if wio.config.get("server") == 'Customize':
        email = click.prompt(click.style('? ', fg='green') +
            click.style('Please enter your email address', bold=True), type=str)
        password = click.prompt(click.style('? ', fg='green') +
            click.style('Please enter your password', bold=True), hide_input=True, type=str)
        server_url = wio.config.get("mserver")
        
        thread = termui.waiting_echo("Sending login details...")
        thread.daemon = True
        thread.start()
        try:
            json_response = login_wio(server_url, email, password)
            token = json_response['token']
        except Exception as e:
            thread.stop('')
            thread.join()
            click.secho(">> %s" %e, fg='red')
            return
    else:
        token = click.prompt(click.style('? ', fg='green') +
            click.style('First get wio user token from ', bold=True) +
            click.style('https://wio.seeed.io/login', bold=True, fg='green') +
            click.style('\n? ', fg='green') +
            click.style('Then enter token', bold=True), type=str)
        email = ''
        thread = termui.waiting_echo("Checking validity of token...")
        thread.daemon = True
        thread.start()
        try:
            check_token(wio.config.get("mserver"), token)
        except Exception as e:
            thread.stop('')
            thread.join()
            click.secho(">> %s" %e, fg='red')
            return
        # res = login_seeed(email, password) #TODO(ten): next time delete
        # token = res['data']['token']
        # user_id = res['data']['userid']
        # ext_user(wio.config.get("mserver"), email, user_id, token)

    wio.set_config('email', email)
    wio.set_config('token', token)

    thread.stop('')
    thread.join()
    click.secho("\r> ", fg='green', nl=False)
    click.echo("Successfully completed login! Check state, see 'wio state'")