#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdout
from xerox import copy, paste
from clint import piped_in


def xi():
    """Copy to clipboard from stdin or paste to sdout."""
    data = piped_in()
    # if something was piped in, copy it to the clipboard.
    if data:
        copy(data)
    # if nothing was piped in, paste it to stdout.
    else:
        stdout.write(paste())


xi()
